facebook twitter youtube facebook facebook facebook

E-Mail : info@askmlabs.com

Phone : +1.215.353.8306

Home » , , » How To Restore Database From Different Incarnation

How To Restore Database From Different Incarnation

Written By askMLabs on Thursday, April 4, 2013 | 2:10 PM

What is incarnation?
When we open database with RESETLOGS option, the database starts a new incarnation. This new incarnation resets the log sequence number to 1, and then gives the online redo logs a new time stamp and SCN.

When the database starts a new incarnation, are we able to use the old backups taken in previous incarnation for restore and recovery purpose as the present log sequence number is reset to 1.

The present article discusses about the details of how to use the backups in old incarnation for restore and recovery purpose after the database has been opened with resetlogs for many times.

I will explain the details considering a practical approach in our training environment. First i will explain the existing environment and available backups.
Then i will take you to details of how these backups are used to restore and recover to the same server (or to different server) considering that the database has been opened many times with resetlogs option.

Environment Details :
Let us assume that we have a training environment where we have some gold backups for the database. Whenever we do any modification to the database, we will take a new goldbackup and we will keep restoring this latest new backup every week twice( Thursday night and Saturday night).

Following Details shows the different goldbackups available for the training environment.
RMAN> list backup summary;List of Backups
===============
Key     TY LV S Device Type Completion Time #Pieces #Copies Compressed Tag
------- -- -- - ----------- --------------- ------- ------- ---------- ---
327559  B  0  A SBT_TAPE    04-AUG-12       1       1       YES        NOEXPIRE
327560  B  0  A SBT_TAPE    04-AUG-12       1       1       YES        NOEXPIRE
327561  B  0  A SBT_TAPE    04-AUG-12       1       1       YES        NOEXPIRE
327562  B  0  A SBT_TAPE    04-AUG-12       1       1       YES        NOEXPIRE
327785  B  F  A SBT_TAPE    04-AUG-12       1       1       NO         NOEXPIRE
351357  B  0  A SBT_TAPE    13-OCT-12       1       1       YES        NOEXPIRE
351358  B  0  A SBT_TAPE    13-OCT-12       1       1       YES        NOEXPIRE
351359  B  0  A SBT_TAPE    13-OCT-12       1       1       YES        NOEXPIRE
351360  B  0  A SBT_TAPE    13-OCT-12       1       1       YES        NOEXPIRE
351583  B  F  A SBT_TAPE    13-OCT-12       1       1       NO         NOEXPIRE
355951  B  0  A SBT_TAPE    27-OCT-12       1       1       YES        NOEXPIRE
355952  B  0  A SBT_TAPE    27-OCT-12       1       1       YES        NOEXPIRE
355953  B  0  A SBT_TAPE    27-OCT-12       1       1       YES        NOEXPIRE
355954  B  0  A SBT_TAPE    27-OCT-12       1       1       YES        NOEXPIRE
356177  B  F  A SBT_TAPE    27-OCT-12       1       1       NO         NOEXPIRE
386046  B  0  A SBT_TAPE    26-JAN-13       1       1       YES        NOEXPIRE
386047  B  0  A SBT_TAPE    26-JAN-13       1       1       YES        NOEXPIRE
386048  B  0  A SBT_TAPE    26-JAN-13       1       1       YES        NOEXPIRE
386049  B  0  A SBT_TAPE    26-JAN-13       1       1       YES        NOEXPIRE
386275  B  F  A SBT_TAPE    26-JAN-13       1       1       NO         NOEXPIRE
387232  B  0  A SBT_TAPE    29-JAN-13       1       1       YES        NOEXPIRE
387233  B  0  A SBT_TAPE    29-JAN-13       1       1       YES        NOEXPIRE
387234  B  0  A SBT_TAPE    29-JAN-13       1       1       YES        NOEXPIRE
387235  B  0  A SBT_TAPE    29-JAN-13       1       1       YES        NOEXPIRE
387462  B  F  A SBT_TAPE    29-JAN-13       1       1       NO         NOEXPIRE
392057  B  0  A SBT_TAPE    09-FEB-13       1       1       YES        NOEXPIRE
392058  B  0  A SBT_TAPE    09-FEB-13       1       1       YES        NOEXPIRE
392059  B  0  A SBT_TAPE    09-FEB-13       1       1       YES        NOEXPIRE
392060  B  0  A SBT_TAPE    09-FEB-13       1       1       YES        NOEXPIRE
392286  B  F  A SBT_TAPE    09-FEB-13       1       1       NO         NOEXPIRE
392347  B  F  A SBT_TAPE    09-FEB-13       1       1       NO         TAG20130209T021024

RMAN>


So everytime when we restore the database from the latest gold backup, we will open the database with resetlogs option and it starts a new incarnation.
These details are shown below ..
RMAN> list incarnation of database TRNGDB;
List of Database Incarnations
DB Key  Inc Key DB Name  DB ID            STATUS  Reset SCN  Reset Time
------- ------- -------- ---------------- --- ---------- ----------
......
.......
158938  325435  TRNGDB   3679252776       ORPHAN  88080533256 29-JUL-12
158938  326880  TRNGDB   3679252776       PARENT  88080533256 02-AUG-12
158938  323440  TRNGDB   3679252776       ORPHAN  88080533256 26-JUL-12
158938  330059  TRNGDB   3679252776       ORPHAN  88080774587 09-AUG-12
158938  332058  TRNGDB   3679252776       ORPHAN  88080774587 12-AUG-12
158938  335023  TRNGDB   3679252776       ORPHAN  88080774587 23-AUG-12
158938  334177  TRNGDB   3679252776       ORPHAN  88080774587 19-AUG-12
158938  350823  TRNGDB   3679252776       PARENT  88080774587 11-OCT-12
158938  350133  TRNGDB   3679252776       ORPHAN  88080774587 07-OCT-12
158938  337328  TRNGDB   3679252776       ORPHAN  88080774587 26-AUG-12
158938  338003  TRNGDB   3679252776       ORPHAN  88080774587 30-AUG-12
158938  339685  TRNGDB   3679252776       ORPHAN  88080774587 02-SEP-12
158938  340363  TRNGDB   3679252776       ORPHAN  88080774587 06-SEP-12
158938  342063  TRNGDB   3679252776       ORPHAN  88080774587 09-SEP-12
158938  342743  TRNGDB   3679252776       ORPHAN  88080774587 13-SEP-12
158938  344429  TRNGDB   3679252776       ORPHAN  88080774587 16-SEP-12
158938  346103  TRNGDB   3679252776       ORPHAN  88080774587 23-SEP-12
158938  347243  TRNGDB   3679252776       ORPHAN  88080774587 27-SEP-12
158938  348499  TRNGDB   3679252776       ORPHAN  88080774587 30-SEP-12
158938  349183  TRNGDB   3679252776       ORPHAN  88080774587 04-OCT-12
158938  352901  TRNGDB   3679252776       ORPHAN  88081045250 18-OCT-12
158938  354443  TRNGDB   3679252776       ORPHAN  88081045250 21-OCT-12
158938  355286  TRNGDB   3679252776       PARENT  88081045250 25-OCT-12
158938  364387  TRNGDB   3679252776       ORPHAN  88081234176 22-NOV-12
158938  363526  TRNGDB   3679252776       ORPHAN  88081234176 18-NOV-12
158938  362107  TRNGDB   3679252776       ORPHAN  88081234176 15-NOV-12
158938  361247  TRNGDB   3679252776       ORPHAN  88081234176 11-NOV-12
158938  359827  TRNGDB   3679252776       ORPHAN  88081234176 08-NOV-12
158938  358965  TRNGDB   3679252776       ORPHAN  88081234176 04-NOV-12
158938  357545  TRNGDB   3679252776       ORPHAN  88081234176 01-NOV-12
158938  365807  TRNGDB   3679252776       ORPHAN  88081234176 25-NOV-12
158938  384807  TRNGDB   3679252776       PARENT  88081234176 24-JAN-13
158938  383953  TRNGDB   3679252776       ORPHAN  88081234176 20-JAN-13
158938  382547  TRNGDB   3679252776       ORPHAN  88081234176 17-JAN-13
158938  381687  TRNGDB   3679252776       ORPHAN  88081234176 13-JAN-13
158938  380267  TRNGDB   3679252776       ORPHAN  88081234176 10-JAN-13
158938  379411  TRNGDB   3679252776       ORPHAN  88081234176 06-JAN-13
158938  378007  TRNGDB   3679252776       ORPHAN  88081234176 03-JAN-13
158938  377152  TRNGDB   3679252776       ORPHAN  88081234176 30-DEC-12
158938  375747  TRNGDB   3679252776       ORPHAN  88081234176 27-DEC-12
158938  374892  TRNGDB   3679252776       ORPHAN  88081234176 23-DEC-12
158938  373487  TRNGDB   3679252776       ORPHAN  88081234176 20-DEC-12
158938  372631  TRNGDB   3679252776       ORPHAN  88081234176 16-DEC-12
158938  371227  TRNGDB   3679252776       ORPHAN  88081234176 13-DEC-12
158938  366667  TRNGDB   3679252776       ORPHAN  88081234176 29-NOV-12
158938  368086  TRNGDB   3679252776       ORPHAN  88081234176 02-DEC-12
158938  368947  TRNGDB   3679252776       ORPHAN  88081234176 06-DEC-12
158938  370366  TRNGDB   3679252776       ORPHAN  88081234176 09-DEC-12
158938  391514  TRNGDB   3679252776       PARENT  88082816786 07-FEB-13
158938  387719  TRNGDB   3679252776       ORPHAN  88082816786 01-FEB-13
158938  390618  TRNGDB   3679252776       ORPHAN  88082816786 03-FEB-13
158938  404336  TRNGDB   3679252776       ORPHAN  88082894636 21-FEB-13
158938  403425  TRNGDB   3679252776       ORPHAN  88082894636 17-FEB-13
158938  401240  TRNGDB   3679252776       ORPHAN  88082894636 14-FEB-13
158938  416836  TRNGDB   3679252776       CURRENT 88082894636 21-MAR-13
158938  412180  TRNGDB   3679252776       ORPHAN  88082894636 10-MAR-13
158938  409274  TRNGDB   3679252776       ORPHAN  88082894636 03-MAR-13
158938  415096  TRNGDB   3679252776       ORPHAN  88082894636 17-MAR-13
158938  413356  TRNGDB   3679252776       ORPHAN  88082894636 14-MAR-13
158938  406349  TRNGDB   3679252776       ORPHAN  88082894636 24-FEB-13
158938  407256  TRNGDB   3679252776       ORPHAN  88082894636 28-FEB-13
158938  410176  TRNGDB   3679252776       ORPHAN  88082894636 07-MAR-13

RMAN>


As long as i am restoring the latest goldbackups to the training environment, it uses the current incarnation and able to restore the latest backups and able to open the database with resetlogs option.

But if i want to restore any previous backups(backups taken at a different incarnation) to the training environment,i may not be able to restore the backups to the current incarnation.

Let us assume that i have my latest backups available on 09-OCT-2013 as per the above details and my current incarnation is 416836 (on 21-MAR-2013).
Now i have a requirement where i need to restore the backups available on 27-OCT-2012 to the same server. So as long as my current incarnation is 416836, i will not be able to use these backups on 27-OCT-2012 to restore the database.
So i need to first change the incarnation to be able to restore the backups on 27-OCT-2012.

For your easy understanding to identify to which incarnation to change, i have mixed backup details and incarnation details and orderded the details date wise below ....
158938  349183  TRNGDB   3679252776       ORPHAN  88080774587 04-OCT-12
13-OCT-12  <<<== Date on which we have Backups
158938  350133  TRNGDB   3679252776       ORPHAN  88080774587 07-OCT-12
158938  350823  TRNGDB   3679252776       PARENT  88080774587 11-OCT-12
158938  352901  TRNGDB   3679252776       ORPHAN  88081045250 18-OCT-12
158938  354443  TRNGDB   3679252776       ORPHAN  88081045250 21-OCT-12
158938  355286  TRNGDB   3679252776       PARENT  88081045250 25-OCT-12
27-OCT-12 <<<== Date on which we have  Backups
158938  357545  TRNGDB   3679252776       ORPHAN  88081234176 01-NOV-12
158938  358965  TRNGDB   3679252776       ORPHAN  88081234176 04-NOV-12
158938  359827  TRNGDB   3679252776       ORPHAN  88081234176 08-NOV-12
158938  361247  TRNGDB   3679252776       ORPHAN  88081234176 11-NOV-12
158938  362107  TRNGDB   3679252776       ORPHAN  88081234176 15-NOV-12
158938  363526  TRNGDB   3679252776       ORPHAN  88081234176 18-NOV-12
158938  364387  TRNGDB   3679252776       ORPHAN  88081234176 22-NOV-12
158938  365807  TRNGDB   3679252776       ORPHAN  88081234176 25-NOV-12
158938  366667  TRNGDB   3679252776       ORPHAN  88081234176 29-NOV-12

When a database goes through multiple incarnations, some backups can become orphaned. The simple way to find non-orphaned backups and orphaned backups are to form a table to list the incarnation number and orphaned and non-orphaned backups to each incarnation.
In our case, in simple words, we need to restore backups from 27-OCT-12. So identify the incarnation number for which this backup is non-orphaned.

I am considering the incarnation before and after the 27-OCT-12 to identify orphaned and non-orphaned backups. We have incarnations 357545(on 01-NOV-12)  and 355286 (25-OCT-12).
For incarnation 357545(on 01-NOV-12) : All the backups taken after the date 01-NOV-2012 are non-orphaned and all the backups before this incarnation are orphaned backups assuming that there is no other incarnation after the incarnation 357545. So in our case the backups on 27-OCT-2012 are orphaned backups if i set incarnation 357545.


For incarnation 355286(on 25-OCT-12) : All the backups taken after the date 25-OCT-2012 are non-orphaned and all the backups before this incarnation are orphaned backups assuming that there is no other incarnation after the incarnation 355286. So in our case the backups on 27-OCT-2012 are non-orphaned backups if i set incarnation 355286.

Now we have the details, which incarnation we need to set for restoring the 27-OCT-2012 backups.

Also get the controlfile information from the 27-OCT-2012 backups using
RMAN> list backup of controlfile;

NOTE : In our case the controlfile details are '4vnoosbv_1_1'

Then use the following syntax to restore and recover the database...
RMAN> set dbid=3679252776
executing command: SET DBID
database name is "TRNGDB" and DBID is 3679252776

RMAN> RESET DATABASE TO INCARNATION 355286;

database reset to incarnation 355286

RMAN>  run {
2> allocate channel t1 type 'SBT_TAPE' parms="ENV=(TDPO_OPTFILE=/tmp/askm/TRNGDB_tdpo.opt)";
3> restore controlfile from '4vnoosbv_1_1';
4> }

allocated channel: t1
channel t1: SID=396 device type=SBT_TAPE
channel t1: Data Protection for Oracle: version 5.5.2.0

Starting restore at 22-MAR-13

channel t1: restoring control file
channel t1: restore complete, elapsed time: 00:00:01
output file name=/u01/oradata/TRNGDB/control01.ctl
output file name=/u01/oradata/TRNGDB/control02.ctl
output file name=/u01/oradata/TRNGDB/control03.ctl
Finished restore at 22-MAR-13
released channel: t1

RMAN> run {
2> allocate channel t1 type 'SBT_TAPE' parms="ENV=(TDPO_OPTFILE=/tmp/askm/TRNGDB_tdpo.opt)";
3> restore controlfile from '4vnoosbv_1_1';
4> alter database mount;
5> restore database;
6> recover database noredo;
7> release channel t1;
8> }

allocated channel: t1
channel t1: SID=396 device type=SBT_TAPE
channel t1: Data Protection for Oracle: version 5.5.2.0

Starting restore at 22-MAR-13

channel t1: restoring control file
channel t1: restore complete, elapsed time: 00:00:01
output file name=/u01/oradata/TRNGDB/control01.ctl
output file name=/u01/oradata/TRNGDB/control02.ctl
output file name=/u01/oradata/TRNGDB/control03.ctl
Finished restore at 22-MAR-13

database mounted

Starting restore at 22-MAR-13

channel t1: starting datafile backup set restore
channel t1: specifying datafile(s) to restore from backup set
channel t1: restoring datafile 00003 to /u01/oradata/TRNGDB/sysaux01.dbf
channel t1: restoring datafile 00004 to /u01/oradata/TRNGDB/psdefault.dbf
channel t1: restoring datafile 00009 to /u01/oradata/TRNGDB/aalarge.dbf
channel t1: restoring datafile 00011 to /u01/oradata/TRNGDB/adapp.dbf
channel t1: restoring datafile 00012 to /u01/oradata/TRNGDB/adapp001002.dbf
channel t1: restoring datafile 00014 to /u01/oradata/TRNGDB/avapp.dbf
channel t1: restoring datafile 00015 to /u01/oradata/TRNGDB/avapp001002.dbf
channel t1: restoring datafile 00017 to /u01/oradata/TRNGDB/avapp001004.dbf
channel t1: restoring datafile 00022 to /u01/oradata/TRNGDB/ccapp.dbf
channel t1: restoring datafile 00030 to /u01/oradata/TRNGDB/cularg3.dbf
channel t1: restoring datafile 00031 to /u01/oradata/TRNGDB/diapp.dbf
channel t1: restoring datafile 00036 to /u01/oradata/TRNGDB/faapp001002.dbf
channel t1: restoring datafile 00038 to /u01/oradata/TRNGDB/fgapp.dbf
channel t1: restoring datafile 00041 to /u01/oradata/TRNGDB/giapp.dbf
channel t1: restoring datafile 00043 to /u01/oradata/TRNGDB/glapp.dbf
channel t1: restoring datafile 00047 to /u01/oradata/TRNGDB/hpapp001002.dbf
channel t1: restoring datafile 00054 to /u01/oradata/TRNGDB/hrapp4001002.dbf
channel t1: restoring datafile 00063 to /u01/oradata/TRNGDB/hrwork001002.dbf
channel t1: restoring datafile 00065 to /u01/oradata/TRNGDB/htapp001002.dbf
channel t1: restoring datafile 00067 to /u01/oradata/TRNGDB/inlarge.dbf
channel t1: restoring datafile 00068 to /u01/oradata/TRNGDB/paapp.dbf
channel t1: restoring datafile 00069 to /u01/oradata/TRNGDB/paapp001001.dbf
channel t1: restoring datafile 00070 to /u01/oradata/TRNGDB/palarge.dbf
channel t1: restoring datafile 00077 to /u01/oradata/TRNGDB/piwork001002.dbf
channel t1: restoring datafile 00081 to /u01/oradata/TRNGDB/psindx001002.dbf
channel t1: restoring datafile 00085 to /u01/oradata/TRNGDB/psindx001006.dbf
channel t1: restoring datafile 00086 to /u01/oradata/TRNGDB/psindx001007.dbf
channel t1: restoring datafile 00089 to /u01/oradata/TRNGDB/psindx001010.dbf
channel t1: restoring datafile 00098 to /u01/oradata/TRNGDB/ptcmstar.dbf
channel t1: restoring datafile 00100 to /u01/oradata/TRNGDB/ptprc.dbf
channel t1: restoring datafile 00107 to /u01/oradata/TRNGDB/pttlrg001002.dbf
channel t1: restoring datafile 00115 to /u01/oradata/TRNGDB/pywork.dbf
channel t1: restoring datafile 00121 to /u01/oradata/TRNGDB/saapp001005.dbf
channel t1: restoring datafile 00125 to /u01/oradata/TRNGDB/salarge.dbf
channel t1: restoring datafile 00136 to /u01/oradata/TRNGDB/tlapp001002.dbf
channel t1: restoring datafile 00140 to /u01/oradata/TRNGDB/tlwork001001.dbf
channel t1: restoring datafile 00142 to /u01/oradata/TRNGDB/waapp.dbf
channel t1: restoring datafile 00147 to /u01/oradata/TRNGDB/rbks001002.dbf
channel t1: restoring datafile 00149 to /u01/oradata/TRNGDB/epapp001001.dbf
channel t1: restoring datafile 00161 to /u01/oradata/TRNGDB/eoeiapp001001.dbf
channel t1: restoring datafile 00162 to /u01/oradata/TRNGDB/eodsapp001001.dbf
channel t1: restoring datafile 00166 to /u01/oradata/TRNGDB/hrslarge001001.dbf
channel t1: restoring datafile 00170 to /u01/oradata/TRNGDB/eopplrg001001.dbf
channel t1: restoring datafile 00174 to /u01/oradata/TRNGDB/eocuapp001001.dbf
channel t1: restoring datafile 00178 to /u01/oradata/TRNGDB/eoeilrg001001.dbf
channel t1: restoring datafile 00182 to /u01/oradata/TRNGDB/eoiuwrk001001.dbf
channel t1: restoring datafile 00186 to /u01/oradata/TRNGDB/erwork001001.dbf
channel t1: restoring datafile 00190 to /u01/oradata/TRNGDB/hrlarg1001001.dbf
channel t1: restoring datafile 00192 to /u01/oradata/TRNGDB/psimgr001001.dbf
channel t1: restoring datafile 00196 to /u01/oradata/TRNGDB/pswork001001.dbf
channel t1: restoring datafile 00200 to /u01/oradata/TRNGDB/hrapp001004.dbf
channel t1: restoring datafile 00203 to /u01/oradata/TRNGDB/clnd001001.dbf
channel t1: restoring datafile 00205 to /u01/oradata/TRNGDB/clnd001002
channel t1: reading from backup piece backup_TRNGDB_3679252776_set155_piece1_copy1_20121027_4rnoorig_1_1
channel t1: piece handle=backup_TRNGDB_3679252776_set155_piece1_copy1_20121027_4rnoorig_1_1 tag=NOEXPIRE

..
....
RMAN> alter database open resetlogs;

database opened
new incarnation of database registered in recovery catalog
starting full resync of recovery catalog
full resync complete

RMAN> exit


So we are able to successfully restore the backups from a different incarnation. The same procedure can be applied if you plan to restore the database to a different server as long as the tsm configuration is properly done.

Hope It Helps

SRI
Share this article :

Related Articles By Category



Post a Comment

Thank you for visiting our site and leaving your valuable comment.

 
Support :
Copyright © 2013. askMLabs - All Rights Reserved
Proudly powered by Blogger