Oracle RMAN 11g Backup and Recovery (120 page)

348
Part III: Using RMAN Effectively

of the
recover
command, Oracle will apply the archived redo logs (and any incremental backups that need to be applied) up to, but not including, the defined recovery target.

NOTE

If you are trying to recover to the point of completion of a specific
backup, you must recover to the CKP SCN or CKP TIME of the files in

the backup set as listed in the RMAN
list
command for the different
backup sets (for example,
list backupset
). Using the CKP TIME of
the backup is not sufficient and can lead to ORA-1152 errors.

You can also opt to use the
until time
,
until SCN
, or
until sequence
commands directly in the
restore
and
recover
commands, which eliminates the need for the
run
block entirely (which we prefer). Here is an example of the use of the
until time
command when restoring and recovering a database:

-- We assume that your control file is intact

startup mount;

restore database UNTIL TIME

"TO DATE('06/28/06 13:00:00','MM/DD/YY HH24:MI:SS')";

recover database UNTIL TIME

"TO DATE('06/28/06 13:00:00','MM/DD/YY HH24:MI:SS')";

alter database open resetlogs;

Time-Based Recovery

In the previous section, we provided some examples of time-based recovery. This type of recovery allows you to recover the database as it looked consistently at a specific time. Of course, if you don’t have backups or archived redo logs available to restore the database to the time you are requesting, then Oracle will generate an error somewhat like this one:

RMAN-00571:

RMAN-00569:

ERROR MESSAGE STACK FOLLOWS

RMAN-00571:

RMAN-03002: failure of restore command at 07/02/2006 21:33:02

RMAN-20207: UNTIL TIME or RECOVERY WINDOW is before RESETLOGS time

The bottom line is that you need to make sure you have a backup of your database that was taken before the time you wish to recover to. You also need all of your archived redo logs. In Chapter 15, we discuss the
list
and
report
commands that allow you to determine what backups are available for RMAN to restore from.

SCN-Based Recovery

We talked about the SCN in detail in Chapter 1. Oracle allows you to recover the database to a specific SCN. In practice, this is not a frequently used recovery method, but it’s nice to know it’s available. We will use it later in this chapter to recover to a previous database incarnation. Here is an example of a recovery to a specific SCN:

-- We assume that your control file is intact

startup mount;

Chapter 14: RMAN Advanced Recovery Topics
349

restore database UNTIL SCN 10000;

recover database UNTIL SCN 10000;

alter database open resetlogs;

In this case, we restore up to, but not including, SCN 10000.

Log Sequence–Based Recovery

RMAN allows you to perform a recovery up to a specific archived redo log sequence number.

This is handy if there is a gap in your archived redo logs, which generally means that you can recover only up to the point where the gap begins. Here is the command to perform this recovery in RMAN:

-- We assume that your control file is intact

startup mount;

restore database UNTIL SEQUENCE 100 thread 1;

recover database UNTIL SEQUENCE 100 thread 1;

alter database open resetlogs;

In this case, we restore up to, but not including, log sequence 100 of thread 1.

Cancel-Based Recovery

RMAN doesn’t support cancel-based recovery like SQL*Plus does (though, in a way, cancel-based recovery is much like log sequence–based recovery). RMAN expects you to know what time, SCN, or log sequence number you want to recover to, and that makes sense. If you have some need to perform cancel-based recovery, you need to restore the datafiles from RMAN to some time before the point in time you are going to recover to. You need to manually extract the archived redo logs that you will need for the cancel-based recovery, and then you need to perform cancel-based recovery of the database from the SQL*Plus client. Chapter 1 describes the process of performing manual cancel-based database recovery.

Recovery Using Restore Points

You can use restore points to define the point in time that you want to restore your database to. To restore a database based on a restore point, simply include the
to restore point
clause of the
restore
and
recover
commands, as seen in this example:

Startup mount;

Restore database until restore point TANGO ONE;

Recover database until restore point TANGO ONE;

Alter database open resetlogs;

You can also use a
run
block and use the
set until restore point
command to establish the target restore point, for example:

Startup mount;

run {

set restore point TANGO ONE;

Restore database TANGO ONE;

Recover database TANGO ONE; }

Alter database open resetlogs;

350
Part III: Using RMAN Effectively

Other books

THE PUPPETEERS OF PALEM by Komarraju, Sharath
Shady Lady by Aguirre, Ann
The Presence by Eve Bunting
My Own Two Feet by Beverly Cleary
Cross and Burn by Val McDermid
Stay:The Last Dog in Antarctica by Blackadder, Jesse