Oracle 11g RMAN: Restore SPFILE using AUTOBACKUP with non-default location and non-default name


One of the common scenarios for recovering from database failures is the loss of the spfile and/or controlfile, usually following failures on the database storage media (for example a SAN storage failure). Therefore it is very useful to have an automatic backup of the controlfile that is created whenever there are changes to the total number of datafiles, online redo logs and whenever the SYSTEM tablespace is backed up)

Even since Oracle 10g it has been possible to do this, with the proviso that the naming convention for the controlfile autobackup is the default format, or %F. If it is using a non-default naming convention, there’s an additional RMAN configuration that must be done during the restore.

To create a backup of the current controlfile (and also to enable the controlfile autobackup feature), we would need to

       i.          configure RMAN parameter to turn on autobackup of controlfiles

      ii.          configure RMAN parameter to specify a location where these backups would be created (in my case in a disk directory named /oracle/rmanbkp)

     iii.          configure RMAN naming format for controlfile autobackup (using the default %F format)

     iv.          run the BACKUP CURRENT CONTROLFILE RMAN command

 

To illustrate:

$ rman target /

Recovery Manager: Release 11.2.0.2.0 – Production on Thu Jun 9 14:43:20 2011

Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.

connected to target database: OCMDB (DBID=4095510504)

 

run

{

CONFIGURE CONTROLFILE AUTOBACKUP ON;

CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO ‘/oracle/rmanbkp/ocmdb/%F’;

backup current controlfile;

}

RMAN> 2> 3> 4> 5> 6>

 

old RMAN configuration parameters:

CONFIGURE CONTROLFILE AUTOBACKUP ON;

new RMAN configuration parameters:

CONFIGURE CONTROLFILE AUTOBACKUP ON;

new RMAN configuration parameters are successfully stored

 

old RMAN configuration parameters:

CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO ‘/oracle/rmanbkp/ocmdb/%F’;

new RMAN configuration parameters:

CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO ‘/oracle/rmanbkp/ocmdb/%F’;

new RMAN configuration parameters are successfully stored

 

Starting backup at 10-JUN-11

allocated channel: ORA_DISK_1

channel ORA_DISK_1: SID=105 device type=DISK

channel ORA_DISK_1: starting compressed full datafile backup set

channel ORA_DISK_1: specifying datafile(s) in backup set

including current control file in backup set

channel ORA_DISK_1: starting piece 1 at 10-JUN-11

channel ORA_DISK_1: finished piece 1 at 10-JUN-11

piece handle=/oracle/rmanbkp/ocmdb/1omehfht_1_1 tag=TAG20110610T114917 comment=NONE

channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01

Finished backup at 10-JUN-11

 

Starting Control File and SPFILE Autobackup at 10-JUN-11

piece handle=/oracle/rmanbkp/ocmdb/c-4095510504-20110610-04 comment=NONE

Finished Control File and SPFILE Autobackup at 10-JUN-11

 

 

A file with this format would be created at the /oracle/rmanbkp directory with a name similar to the following:

c-4095510504-20110610-06

where the following sections signify:

Portion of filename Description
c Signifies an automatic backup of the controlfile
4095510504 The database identifier (DBID) for the database
20110609 Date when the controlfile autobackup was created, in the format YYYYMMDD
06 Sequence of autobackup (first autobackup of the day would be 01, second is 02, etc etc)

              

In situations where there has been media failure on the default backup destination (/oracle/rmanbkp in my example), there may be a need to restore the spfile from a new location (for example /u01). We can proceed in the following method for Oracle 11g in this case. Note that I have first shutdown the database cleanly and removed the SPFILE for this particular database from the $ORACLE_HOME/dbs directory.

Additionally, to simulate a media failure of the primary backup location, I have created a new folder /u01, and moved the generated autobackup to this location, and renamed the file to test_ c-4095510504-20110610-06 (test_%F).

 

set dbid 4095510504;

run

{

startup nomount;

allocate channel c1 device type disk;

set controlfile autobackup format for device type disk to ‘/u01/test_%F’;

restore spfile from autobackup;

}

executing command: SET DBID

 

RMAN> 2> 3> 4> 5> 6> 7>

 

database is already started

 

allocated channel: c1

channel c1: SID=95 device type=DISK

 

executing command: SET CONTROLFILE AUTOBACKUP FORMAT

 

Starting restore at 10-JUN-11

 

channel c1: looking for AUTOBACKUP on day: 20110610

channel c1: AUTOBACKUP found: /u01/test_c-4095510504-20110610-06

channel c1: restoring spfile from AUTOBACKUP /u01/test_c-4095510504-20110610-06

channel c1: SPFILE restore from AUTOBACKUP complete

Finished restore at 10-JUN-11

released channel: c1

About oracletempspace

I'm an Oracle enthusiast, whose work revolves around consulting, designing, implementing and generally helping businesses get the most out of Oracle Database and related products.
This entry was posted in Backup and recovery, Oracle 11g Release 2, Recovery Manager (RMAN), Recovery Manager (RMAN) and tagged , , , . Bookmark the permalink.

1 Response to Oracle 11g RMAN: Restore SPFILE using AUTOBACKUP with non-default location and non-default name

  1. Pingback: control file « Prayag Upd

Leave a comment