RMAN: How to identify the latest controlfile backup piece

We need to restore the full database from the backups we have created. First thing we need to restore is the controlfile. Now question is how to identify the latest controlfile backup piece.

There is no direct mechanism available to identify latest controlfile backup piece. But we’ll have to use one of the following options

1. Check rman logs (if available)

2. Check available backup directories. Controlfile backups are small in size as compared to other backups.

3. Check if the autobackups are available

Once the controlfile is identified we can restore it as following

RMAN> restore controlfile from  {'<path>' | autobackup};
Starting restore at 28-OCT-11 using channel ORA_DISK_1
channel ORA_DISK_1: restoring control file 
channel ORA_DISK_1: restore complete, elapsed time: 00:00:17 
output filename=<control file 1> 
output filename=<control file 2> 
Finished restore at 28-OCT-11

If controlfile is to be restored from the TAPE

RMAN> SET DBID <dbid>;
RMAN> run 
{ 
allocate channel c1 type sbt_tape; 
restore controlfile from {<path> | autobackup}; 
}
using target database control file instead of recovery catalog 
allocated channel: c1 
channel c1: sid=1091 devtype=SBT_TAPE 
channel c1: Oracle Secure Backup Starting restore at Nov 27 2011
channel c1: control file restore from autobackup complete 
output filename=<control file 1> 
output filename=<control file 2> 
Finished restore at Nov 27 2011 23:47:44 
released channel: c1

Note: We may have multiple backups of the controlfile created on a particular day. If we use restore from autobackup, rman uses latest autobackup for that day

For example we have following controlfile backups

2011-11-29 02:00 o1_mf_s_768448819_7f7vvhcp_.bkp 
2011-11-29 03:00 o1_mf_s_768452424_7f7zd4m2_.bkp 
2011-11-29 04:00 o1_mf_s_768456021_7f82wt7s_.bkp 
2011-11-29 06:00 o1_mf_s_768463224_7f89xoxy_.bkp 
2011-11-29 07:00 o1_mf_s_768466818_7f8ffypp_.bkp 
2011-11-29 08:00 o1_mf_s_768470419_7f8jyk2p_.bkp 
2011-11-29 09:00 o1_mf_s_768474018_7f8ngyt5_.bkp 
2011-11-29 10:00 o1_mf_s_768477620_7f8qzkxs_.bkp 
2011-11-29 12:00 o1_mf_s_768484828_7f8z0qyy_.bkp 
2011-11-29 13:00 o1_mf_s_768488417_7f92jwf8_.bkp 
2011-11-29 14:00 o1_mf_s_768492018_7f961h6v_.bkp 
2011-11-29 15:00 o1_mf_s_768495617_7f99kykg_.bkp 
2011-11-29 16:00 o1_mf_s_768499218_7f9f2hth_.bkp

RMAN> restore controlfile from autobackup preview;

Starting restore at 11/29/2011 16:06:59 allocated channel: 
ORA_DISK_1 channel ORA_DISK_1: SID=113 device type=DISK
recovery area destination: /u04 
database name (or database unique name) used for search: orcl 
channel ORA_DISK_1: AUTOBACKUP 
/u04/orcl/autobackup/2011_11_29/o1_mf_s_768499218_7f9f2hth_.bkp 
found in the recovery area 
channel ORA_DISK_1: looking for AUTOBACKUP on day: 20111129 
Finished restore at 11/29/2011 16:07:06

If we want to restore contolfile from a specific backup, then we need to use “SET UNTIL TIME”

For example, for restoring the controlfile from o1_mf_s_768484828_7f8z0qyy_.bkp, which is created at 12:00

run
{
SET UNTIL TIME "TO_DATE('20111129:12:01','YYYYMMDD:HH24:MI')"; 
RESTORE CONTROLFILE FROM AUTOBACKUP preview;
}

recovery area destination: /u04 
database name (or database unique name) used for search: orcl 
channel ORA_DISK_1: AUTOBACKUP 
/u04/orcl/autobackup/2011_11_29/o1_mf_s_768484828_7f8z0qyy_.bkp 
found in the recovery area 
channel ORA_DISK_1: looking for AUTOBACKUP on day: 20111129 
Finished restore at 11/29/2011 16:18:31

For restoring the controlfile from o1_mf_s_768492018_7f961h6v_.bkp, which is created at 14:00

run
{ 
SET UNTIL TIME "TO_DATE('20111129:14:01','YYYYMMDD:HH24:MI')"; 
RESTORE CONTROLFILE FROM AUTOBACKUP preview; 
}

recovery area destination: /u04 
database name (or database unique name) used for search: orcl 
channel ORA_DISK_1: AUTOBACKUP 
/u04/orcl/autobackup/2011_11_29/o1_mf_s_768492018_7f961h6v_.bkp 
found in the recovery area
channel ORA_DISK_1: looking for AUTOBACKUP on day: 20111129 
Finished restore at 11/29/2011 16:21:04
Advertisements
This entry was posted in Oracle Database Backup, Oracle Recovery Manager and tagged . Bookmark the permalink.

One Response to RMAN: How to identify the latest controlfile backup piece

  1. set dbid=718308982;
    startup nomount;
    set controlfile autobackup format for device type disk to ‘/u01/app/oradata/ACBET/%F’;
    restore controlfile from autobackup;

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s