2019-05-28

Recovering a Database to a Previous Incarnation

Environment

Oracle 12.1, RMAN

Problem

RMAN-06004: ORACLE error from recovery catalog database: RMAN-20207: UNTIL TIME or RECOVERY WINDOW is before RESETLOGS time

Solution

Find a previous incarnation that you need.
Option 1: connect to a target database and catalog, run the following command and choose "Inc Key"
RMAN> LIST INCARNATION OF DATABASE DBPRD1;

Option 2: Connect to the recovery catalog, run the following command and choose DBINC_KEYB. Option 2 is more convenient as it provides more information, e.g. PARENT_DBINC_KEY.
select * from RC_DATABASE_INCARNATION where name='DBPRD1' order by DBINC_KEY;

Then use the incarnation key in RESET DATABASE, exempli gratia:
reset database to incarnation 3587196;
run {
set until time = "to_date('2019-05-27 10:00:00','YYYY-MM-DD HH24:MI:SS')";
allocate channel ch01 type 'SBT_TAPE' PARMS 'some parameters';
restore database;
recover database;
alter database open resetlogs;
}