RMAN Duplicate or restore until what sequence? Use restore preview and SQL

When you restore and recover using an RMAN backup that was in archivelog mode –  at very least – RMAN also needs all the archivelog that was produced while the RMAN backup was being run / generated.
Here is one way to determine what the absolute minimum archivelog sequence that is necessary to restore with an open resetlogs or duplicate statement.
Bottom line:

  • Get the SCN that you have to go past – with RMAN command “restore database preview;”
  • With the output from the “preview” command use the SCN in the line with “Media recovery start” get the sequence of the archivelog then add 1 to that
  • Perform recovery until returned sequence+1

RMAN> restore database preview;
Starting restore at 27-APR-17
using channel ORA_DISK_1
List of Backup Sets
===================
BS Key Type LV Size Device Type Elapsed Time Completion Time
——- —- — ———- ———– ———— —————
3 Full 2.16G DISK 00:00:35 27-APR-17


List of Archived Log Copies for database with db_unique_name GOLD
=====================================================================
Key Thrd Seq S Low Time
——- —- ——- – ———
214 1 311 A 27-APR-17
Name: /u01/app/oracle/fast_recovery_area/GOLD/archivelog/2017_04_27/o1_mf_1_311_dj4xxp0p_.arc
recovery will be done up to SCN 6622680
Media recovery start SCN is 6622680
Recovery must be done beyond SCN 6622680 to clear datafile fuzziness
Finished restore at 27-APR-17
The message “Media recovery start SCN is 6622680” indicates where the archivelog use starts.  So lets query the V$ACHIVELOG view and find the sequence #.
SQL> l
1 select sequence#, first_change#, next_change# from v$archived_log
2 where FIRST_CHANGE# <= 6622680 and NEXT_CHANGE# >= 6622680
3*
SQL> /
SEQUENCE# FIRST_CHANGE# NEXT_CHANGE#
———- ————- ————
311 6622589 6622973
# add 1 to the returned sequence e.g. 311+1
Duplicate database set until sequence=312;
# BTW – While RMAN should go back to previous backups if necessary and extract the necessary archivelogs – if they are in backups – you can explicitly restore archivelogs with an RMAN command like:
restore archivelog from sequence 311;

Leave a Comment

Scroll to Top