Wednesday, 24 May 2017

how to restore the database upto until time( point in time recovery) using RMAN

Let Say you got a request from a application team that , their application upgrade has failed and they wants to restore back the database to back date.

Application team asked you to restore the database to specific date in our case they wants to restore the database to 2017-05-18 22:00 CET

1. We can check by the RMAN preview command if we have available backups to restore or recover the database or not , it will not do the actual restore and recovery , also it will not check that backups are valid to restore or not, we have to use RMAN VALIDATE command in order to check the validity if the backups.

run {
set command id to 'rman restore until time';
set until time "to_date('2017-05-18:22:00:00', 'yyyy-mm-dd:hh24:mi:ss')";
allocate channel t1 type 'sbt_tape' parms
                'ENV=(TDPO_OPTFILE=/opt/tivoli/tsm/client/oracle/bin64/tdpo_sfadb.opt)';
restore database preview;
recover database preview;
}

2. After the successful completion of the above command we can restore/recover the database actually:

run {
set command id to 'rman restore until time';
        set until time "to_date('2017-05-18:22:00:00', 'yyyy-mm-dd:hh24:mi:ss')";
        shutdown abort;
        startup nomount;
        allocate channel t1 type 'sbt_tape' parms
                'ENV=(TDPO_OPTFILE=/opt/tivoli/tsm/client/oracle/bin64/tdpo_sfadb.opt)';
        alter database mount;
        restore database;
        recover database;
        release channel t1;
        sql 'alter database open resetlogs';

No comments:

Post a Comment