Wednesday, July 10, 2013

Tape Database backup restore to a different Host/cluster

restoring a RAC database to single instance on separate cluster/NODE with different file/ASM path from tape

--list of tape backup taken to tape

6688    B  F  A SBT_TAPE    09-JUL-13       1       1       NO         TAG20130709T152555
6689    B  F  A SBT_TAPE    09-JUL-13       1       1       YES        FULLDBORCL_9JULY13
6690    B  F  A SBT_TAPE    09-JUL-13       1       1       YES        FULLDBORCL_9JULY13
6691    B  A  A SBT_TAPE    09-JUL-13       1       1       YES        ARCHIVELOGORCL_9JULY13
6692    B  A  A SBT_TAPE    09-JUL-13       1       1       YES        ARCHIVELOGORCL_9JULY13
6693    B  F  A SBT_TAPE    09-JUL-13       1       1       YES        ORCL_CONTROLFILE
6694    B  F  A SBT_TAPE    09-JUL-13       1       1       NO         TAG20130709T153601

=========================================================================================================================================
BACKUP INFORMATION DETAILS from RMAN PROMPT (NOTE: the last SCN in archivelog backup is 93413348 this would be used in recovery purpose)
=========================================================================================================================================

BS Key  Type LV Size       Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
6689    Full    262.00M    SBT_TAPE    00:04:25     09-JUL-13
        BP Key: 6689   Status: AVAILABLE  Compressed: YES  Tag: FULLDBORCL_9JULY13
        Handle: peoeamcb_1_1   Media: Z05723
  List of Datafiles in backup set 6689
  File LV Type Ckp SCN    Ckp Time  Name
  ---- -- ---- ---------- --------- ----
  3       Full 93412607   09-JUL-13 +SDATA/ORCL/datafile/undotbs1.389.812985451
................
...................
...................
  32      Full 93412607   09-JUL-13 +SDATA/ORCL/datafile/undotbs4.3054.815489519

BS Key  Type LV Size       Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
6690    Full    761.00M    SBT_TAPE    00:07:06     09-JUL-13
        BP Key: 6690   Status: AVAILABLE  Compressed: YES  Tag: FULLDBORCL_9JULY13
        Handle: pdoeamca_1_1   Media: X08001
  List of Datafiles in backup set 6690
  File LV Type Ckp SCN    Ckp Time  Name
  ---- -- ---- ---------- --------- ----
  1       Full 93412598   09-JUL-13 +SDATA/ORCL/datafile/system.387.812985451
 .............
...............
..............
  30      Full 93412598   09-JUL-13 +SDATA/ORCL/datafile/wcc_cons.399.812985475

BS Key  Size       Device Type Elapsed Time Completion Time
------- ---------- ----------- ------------ ---------------
6691    512.00K    SBT_TAPE    00:02:49     09-JUL-13
        BP Key: 6691   Status: AVAILABLE  Compressed: YES  Tag: ARCHIVELOGORCL_9JULY13
        Handle: pgoeampp_1_1   Media: X08878

  List of Archived Logs in backup set 6691
  Thrd Seq     Low SCN    Low Time  Next SCN   Next Time
  ---- ------- ---------- --------- ---------- ---------
  2    535     93412208   09-JUL-13 93413354   09-JUL-13

BS Key  Size       Device Type Elapsed Time Completion Time
------- ---------- ----------- ------------ ---------------
6692    512.00K    SBT_TAPE    00:02:49     09-JUL-13
        BP Key: 6692   Status: AVAILABLE  Compressed: YES  Tag: ARCHIVELOGORCL_9JULY13
        Handle: phoeampp_1_1   Media: X08001

  List of Archived Logs in backup set 6692
  Thrd Seq     Low SCN    Low Time  Next SCN   Next Time
  ---- ------- ---------- --------- ---------- ---------
  1    524     93412212   09-JUL-13 93413348   09-JUL-13

BS Key  Type LV Size       Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
6693    Full    1.25M      SBT_TAPE    00:01:53     09-JUL-13
        BP Key: 6693   Status: AVAILABLE  Compressed: YES  Tag: ORCL_CONTROLFILE
        Handle: pioeamva_1_1   Media: X08001
  Control File Included: Ckp SCN: 93413596     Ckp time: 09-JUL-13

BS Key  Type LV Size       Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
6694    Full    23.50M     SBT_TAPE    00:01:27     09-JUL-13
        BP Key: 6694   Status: AVAILABLE  Compressed: NO  Tag: TAG20130709T153601
        Handle: c-3319723476-20130709-02   Media: X08001
  SPFILE Included: Modification time: 20-JUN-13
  SPFILE db_unique_name: ORCL
  Control File Included: Ckp SCN: 93413798     Ckp time: 09-JUL-13

====================================================================================

--restoring the spfile in destination host/cluster

[export the database name]

[oracle@osubhen-db01 ~]$ . oraenv
ORACLE_SID = [BLAINT1] ? ORCL
ORACLE_HOME = [/home/oracle] ? /oracle/app/database/11.2.0.3/dbhome_1
The Oracle base for ORACLE_HOME=/oracle/app/database/11.2.0.3/dbhome_1 is /oracle/app

[connect to destination database as well to recovery catalog]
[resync the tape backup to recovery catalog(resync catalog) so that we can be able to see the backups from destination server]

[oracle@osubhen-db01 ~]$ rman target / catalog RCAT_OWNER/RC112cat@DEVRCAT

Recovery Manager: Release 11.2.0.3.0 - Production on Thu Jul 11 10:31:53 2013

Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.

connected to target database (not started)
connected to recovery catalog database

-- set the DBID for the destination database (can find it in autobackup of controlfile)

RMAN> set dbid 3319723476

executing command: SET DBID
database name is "ORCL" and DBID is 3319723476

--restore spfile to pfile and modify accordingly

RMAN>
run{
allocate channel c1 type 'SBT_TAPE' parms 'ENV=(NB_ORA_CLASS=x-xxxx-xx-ora-3m-2,NB_ORA_SERV=server.domain.com,NB_ORA_CLIENT= source_server.com.au,NB_ORA_SCHED=oracle_5_years)';
restore spfile to pfile '/oracle/app/database/11.2.0.3/dbhome_1/dbs/initORCL.ora' from tag 'TAG20130709T153601';
}

--sample pfile after modification (note here local_listener change we need to make entry in tnsnames.ora file as well)

[oracle@osubhen-db01 dbs]$ cat initORCL.ora
*.audit_file_dest='/oracle/app/admin/ORCL/adump'
*.audit_trail='db'
*.compatible='11.2.0.0.0'
*.control_file_record_keep_time=31
*.control_files='+DATA01/ORCL/controlfile/current.285.789557145','+DATA01/ORCL/controlfile/current.284.789557145'
*.db_block_size=8192
*.db_create_file_dest='+DATA01'
*.db_domain=''
*.db_name='ORCL'
*.db_recovery_file_dest='+DATA01'
*.db_recovery_file_dest_size=10G
*.diagnostic_dest='/oracle/app'
*.dispatchers='(PROTOCOL=TCP) (SERVICE=ORCLXDB)'
*.log_archive_format='%t_%s_%r.dbf'
*.open_cursors=3000
*.pga_aggregate_target=2G
*.processes=2000
*.remote_login_passwordfile='exclusive'
*.local_listener='LISTENER_ORCL'
*.sessions=2205
*.sga_max_size=4G
*.sga_target=3G

--entry in tnsnames.ora file for local listener
LISTENER_ORCL =
  (ADDRESS = (PROTOCOL = TCP)(HOST = osubhen-db01.espdev.aurdev.national.com.au)(PORT = 1621))


-- start the instance in nomount state with the modified pfile

RMAN> startup nomount pfile='/oracle/app/database/11.2.0.3/dbhome_1/dbs/initORCL.ora'

Oracle instance started

Total System Global Area    4275781632 bytes

Fixed Size                     2235208 bytes
Variable Size               1728054456 bytes
Database Buffers            2533359616 bytes
Redo Buffers                  12132352 bytes

--restore the control file from tape

RMAN> run{
allocate channel c1 type 'SBT_TAPE' parms 'ENV=(NB_ORA_CLASS=x-xxxx-xx-ora-3m-2,NB_ORA_SERV=server.domain.com,NB_ORA_CLIENT= orkxdr2bintdb03-mgtespdev.aurdev.national.com.au,NB_ORA_SCHED=oracle_5_years)';
restore controlfile from tag 'ORCL_CONTROLFILE';
}

allocated channel: c1
channel c1: SID=761 device type=SBT_TAPE
channel c1: Veritas NetBackup for Oracle - Release 6.5 (2010042404)

Starting restore at 11-JUL-13

channel c1: starting datafile backup set restore
channel c1: restoring control file
channel c1: reading from backup piece pioeamva_1_1
channel c1: piece handle=pioeamva_1_1 tag=ORCL_CONTROLFILE
channel c1: restored backup piece 1
channel c1: restore complete, elapsed time: 00:01:25
output file name=+DATA01/ORCL/controlfile/current.631.820492623
output file name=+DATA01/ORCL/controlfile/current.550.820492623
Finished restore at 11-JUL-13
released channel: c1

--mount the database

RMAN> alter database mount;

database mounted

-- run the restore command to restore from tape
--note: here we might need to rename the database files to match the new path/ASM in destination server

run{
allocate channel c1 type 'SBT_TAPE' parms 'ENV=(NB_ORA_CLASS=x-xxxx-xx-ora-3m-2,NB_ORA_SERV=server.domain.com,NB_ORA_CLIENT=source_server.com.au,NB_ORA_SCHED=oracle_5_years)';
set newname for datafile 1 to    '+DATA01/ORCL/datafile/system.387.812985451';
...............
..............
...............
set newname for datafile 32 to    '+DATA01/ORCL/datafile/undotbs4.3054.815489519';

set until SCN 93413348; /**** comment: this SCN can be found from archivelog backup **** /
restore database from tag 'FULLDBORCL_9JULY13';
switch datafile all;
recover database from tag 'ARCHIVELOGORCL_9JULY13';
}


allocated channel: c1
channel c1: SID=761 device type=SBT_TAPE
channel c1: Veritas NetBackup for Oracle - Release 6.5 (2010042404)

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET until clause

Starting restore at 11-JUL-13

channel c1: starting datafile backup set restore
channel c1: specifying datafile(s) to restore from backup set
................
..................
..................
channel c1: restoring datafile 00032 to +DATA01/ORCL/datafile/undotbs4.3054.815489519
channel c1: reading from backup piece peoeamcb_1_1
channel c1: piece handle=peoeamcb_1_1 tag=FULLDBORCL_9JULY13
channel c1: restored backup piece 1
channel c1: restore complete, elapsed time: 00:04:36
channel c1: starting datafile backup set restore
channel c1: specifying datafile(s) to restore from backup set
channel c1: restoring datafile 00001 to +DATA01/ORCL/datafile/system.387.812985451
..................
..................
......................
channel c1: restoring datafile 00030 to +DATA01/ORCL/datafile/wcc_cons.399.812985475
channel c1: reading from backup piece pdoeamca_1_1
channel c1: piece handle=pdoeamca_1_1 tag=FULLDBORCL_9JULY13
channel c1: restored backup piece 1
channel c1: restore complete, elapsed time: 00:08:07
Finished restore at 11-JUL-13

datafile 1 switched to datafile copy
input datafile copy RECID=50 STAMP=820495627 file name=+DATA01/ORCL/datafile/system.509.820495199
datafile 2 switched to datafile copy
..................
..................
...................
datafile 32 switched to datafile copy
input datafile copy RECID=81 STAMP=820495633 file name=+DATA01/ORCL/datafile/undotbs4.681.820495037

Starting recover at 11-JUL-13

starting media recovery

channel c1: starting archived log restore to default destination
channel c1: restoring archived log
archived log thread=2 sequence=535
channel c1: reading from backup piece pgoeampp_1_1
channel c1: piece handle=pgoeampp_1_1 tag=ARCHIVELOGORCL_9JULY13
channel c1: restored backup piece 1
channel c1: restore complete, elapsed time: 00:01:06
channel c1: starting archived log restore to default destination
channel c1: restoring archived log
archived log thread=1 sequence=524
channel c1: reading from backup piece phoeampp_1_1
channel c1: piece handle=phoeampp_1_1 tag=ARCHIVELOGORCL_9JULY13
channel c1: restored backup piece 1
channel c1: restore complete, elapsed time: 00:01:15
archived log file name=+DATA01/ORCL/archivelog/2013_07_11/thread_1_seq_524.846.820495855 thread=1 sequence=524
archived log file name=+DATA01/ORCL/archivelog/2013_07_11/thread_2_seq_535.380.820495775 thread=2 sequence=535
channel default: deleting archived log(s)
archived log file name=+DATA01/ORCL/archivelog/2013_07_11/thread_1_seq_524.846.820495855 RECID=5467 STAMP=820495855
channel default: deleting archived log(s)
archived log file name=+DATA01/ORCL/archivelog/2013_07_11/thread_2_seq_535.380.820495775 RECID=5466 STAMP=820495775
media recovery complete, elapsed time: 00:00:01
Finished recover at 11-JUL-13
released channel: c1

RMAN> alter database open resetlogs;

database opened
new incarnation of database registered in recovery catalog
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of alter db command at 07/11/2013 11:58:10
ORA-01580: error creating control backup file +SFRA/snapcf_dir/snapcf_ORCL_.f
ORA-17502: ksfdcre:3 Failed to create file +SFRA/snapcf_dir/snapcf_ORCL_.f
ORA-15001: diskgroup "SFRA" does not exist or is not mounted
ORA-15001: diskgroup "SFRA" does not exist or is not mounted

RMAN>

-- login and check the status

[oracle@osubhen-db01 admin]$ . oraenv
ORACLE_SID = [+ASM] ? ORCL
ORACLE_HOME = [/home/oracle] ? /oracle/app/database/11.2.0.3/dbhome_1
The Oracle base for ORACLE_HOME=/oracle/app/database/11.2.0.3/dbhome_1 is /oracle/app
[oracle@osubhen-db01 admin]$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.3.0 Production on Thu Jul 11 12:02:01 2013

Copyright (c) 1982, 2011, Oracle.  All rights reserved.


Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
With the Partitioning, Automatic Storage Management, OLAP, Data Mining
and Real Application Testing options

SQL> select name,open_mode,database_role from v$database;

NAME      OPEN_MODE            DATABASE_ROLE
--------- -------------------- ----------------
ORCL  READ WRITE           PRIMARY