Oracle RMAN 11g Backup and Recovery (96 page)

Chapter 12: RMAN Restore and Recovery
275

restore controlfile from autobackup;

shutdown immediate;

You can still recover using the
maxseq
and
maxdays
parameters, as shown in this snippet: restore controlfile from autobackup maxseq 200 maxdays 100;

Recovering Older Control File Backups

You may wish to restore a control file backup that was taken some time ago, such that it’s not the most current backup (this is often the case if you issued a
resetlogs
command). The
restore
controlfile from autobackup
command allows you to do this when coupled with the
until time
parameter. For example, we can find and restore the control file backup created on or before 12/09/2005 at 04:11 A.M. by issuing this command:

restore controlfile from autobackup until time

"to date('12/09/2005 13:00:00','MM/DD/YYYY HH24:MI:SS')";

You will want to know which control file backups are available to restore if you are going to use this command. We discuss the
list
command in more detail in Chapter 18, but for now, you should know that you use the
list backup of controlfile
command to determine which control file backups are available for you to restore. Here is an example:

RMAN> list backup of controlfile;

List of Backup Sets

BS Key Type LV Size Device Type Elapsed Time Completion Time

------- ---- -- ---------- ----------- ------------ ---------------

38 Full 6.80M DISK 00:00:05 01-JAN-06

BP Key: 39 Status: EXPIRED Compressed: NO Tag: TAG20060108T183828

Piece Name: C:\ORACLE\PRODUCT\10.2.0\FLASH RECOVERY AREA\TESTOEM

\AUTOBACKUP\2006 01 08\O1 MF S 579206308 1W3D485F .BKP

Control File Included: Ckp SCN: 3568285 Ckp time: 08-JAN-06

BS Key Type LV Size Device Type Elapsed Time Completion Time

------- ---- -- ---------- ----------- ------------ ---------------

40 Full 6.80M DISK 00:00:06 08-JAN-06

BP Key: 41 Status: AVAILABLE Compressed: NO Tag: TAG20060108T183857

Piece Name: C:\ORACLE\PRODUCT\10.2.0\FLASH RECOVERY AREA\TESTOEM

\AUTOBACKUP\2006 01 08\O1 MF S 579206337 1W3D5495 .BKP

Control File Included: Ckp SCN: 3568311 Ckp time: 08-JAN-06

In the preceding example, we used the
list
command to discover that we have two different control file backups. The first control file backup (BS Key 38) has a status of EXPIRED because of the current backup retention policy. Since it is expired, RMAN will not try to use it during a restore operation (if the backup set piece is still available, we can change the status with the
change
command and be able to use it). The second control file backup (BS Key 40) is available.

RMAN will be able to restore this backup.

Note that the
list
command is only available if you have the database mounted with a current control file. If you do not have a control file available, then the
list
command will not work. Also, if you do not have a control file available, then the retention criteria will not be an issue, and you could restore any control file by using the
autobackup
command.

276
Part II: Setup Principles and Practices

Recover the Control File from a Backup Set

If you used RMAN before Oracle Database 10
g,
you know that recovery of the control file could be difficult if you did not have autobackups configured. In such cases, you needed to write a nasty bit of PL/SQL in order to restore the control file.

Since Oracle Database version 10
g
control file recovery is much easier. Now the
restore
command includes a
from backup
clause that allows you to simply indicate the backup set piece that contains the control file backup in it. Thus, all you need to know is the backup set piece name, and where it is, and you can restore your control file. In some cases, it might take a bit of trial and error to find the backup set piece with the control file backup in it, but once you do, the restore should be a snap (of course, it would be best to restore the most current control file backup!).

To restore the control file, start the database instance and identify the backup set piece that contains the control file (or guess at it). Fire up RMAN. You will need to set the DBID of the database also (as we have already discussed). Once you have set the DBID, you will also need to allocate a channel to the device you are going to restore from. Having allocated the channel, you issue the
restore controlfile from
command, and pass the backup set piece name in the end of the command. RMAN will then restore the control file and replicate it to the different CONTROL_

FILE parameter locations. Here is an example of this type of restore in action: set oracle sid recover

rman target sys/robert

set DBID 2539725638;

startup nomount;

run

{

allocate channel c1 device type disk;

restore controlfile

from 'd:\backup\recover\C-2539725638-20020629-00';

}

shutdown immediate;

You can now perform any additional recovery activities that might be required.

Recovering a Control File Using a Recovery Catalog

If you are using a recovery catalog, restoring the most current control file backup is as simple as issuing the
restore controlfile
command. RMAN will use the recovery catalog to locate the most current control file backup and will extract that backup for your use. Here is an example: set oracle sid recover

rman target sys/robert catalog rcat manager/password@robt

# Note - We would issue a startup nomount

# and restore control file from autobackup here if we needed to.

# shutdown immediate here if we recovered the control file.

startup nomount;

restore controlfile;

# mount the database in preparation for a restore.

alter database mount;

Database Recovery after Restoring a Control File

When you restore a control file with RMAN (and there are no datafiles or online redo logs lost), you have two different things to consider. First, you need to consider how to actually get your

Chapter 12: RMAN Restore and Recovery
277

database up and running after restoring the control file. Second, you need to recover information related to RMAN, such as registering archived redo logs and backup sets in the newly created control file with RMAN. Let’s look at each of these topics in a bit more detail.

Opening the Database after a Control File Recovery
In the event that only your control file was lost, recovery of the control file and your database is generally pretty straightforward (if any kind of Oracle recovery can be thought of as straightforward). The commands to recover the control file are the same; you just need to simulate incomplete recovery in order to open the database. Note that in some cases, you may need to register archived redo logs or even register backup sets before you can complete recovery. We discuss this process in the next section.

Other books

Time of the Locust by Morowa Yejidé
Vengeance Is Mine by Shiden Kanzaki
Tease by Sophie Jordan
Emperor Mage by Pierce, Tamora
Falling Angels by Tracy Chevalier
Nine Buck's Row by Jennifer Wilde
Wolf Blood by N. M. Browne