How to back up and restore the Oracle control file and SPFILE using NetBackup for Oracle with Oracle's autobackup feature.

Article: 100016713
Last Published: 2013-10-24
Ratings: 2 2
Product(s): NetBackup & Alta Data Protection

Problem

How to back up and restore the Oracle control file and SPFILE using NetBackup for Oracle with Oracle's autobackup feature.

Solution

Oracle Recovery Manager (RMAN) Control files store the metadata about backups, archived redo logs, and RMAN's own activities. The SPFILE (also called server parameter file) is an optional, single file which can be located in a selected path or the path auto-designated by Oracle when the file is created. It is similar to the init.ora file as a repository for initialization parameters, but is a binary file that cannot be browsed or edited with a text editor. If the SPFILE exists, it too will be backed up by the auto backup feature. Oracle's auto backup feature was introduced at Oracle 9i (specifically 9.2) as a method to easily and automatically capture the critical information in the control file and SPFILE to be used for disaster recovery.

How it works
Regardless of NetBackup-scheduled control file backups completed within a backup cycle or backup script, RMAN"AUTOBACKUP" will automatically store a copy of the control file that supersedes any previous copy.

If autobackup was used to do the control file backup, it must also be used for the control file restore. If autobackup is not configured correctly in the restore command, the error message "RMAN-06563:control file or SPFILE must be restored using FROM AUTOBACKUP." will be found inthe NetBackup progress log or stdout.
Note: This document assumes NetBackup is already installed and Oracle database backups and restores are already successfully using NetBackup Media Manager for tape storage. All operations below are done as the Oracle user, unless otherwise noted.

Backup
NetBackup does not need any special configuration as long as NetBackup for Oracle backups are already operational for this client. There is no need to name a new policy "autobackup" for example, but keep in mind that the first available policy (alphabetically) that has an open window and supports Oracle backups and this host will be used for the backup.

Keepin mind that the RMAN config parameters used for backup must also be used for restore. Document any configuration changes for future reference.

Turning on "AUTOBACKUP"
If CONFIGURE CONTROLFILE AUTOBACKUP ON (anRMAN command) is issued (set to ON), RMAN performs a control file auto backup (automatic backup) either after every
* BACKUP or COPY command at the RMAN prompt, or
* BACKUP or COPY command within a RUN block (script) that is not followed by another BACKUP or COPY command

Exact steps:
1. On the Oracle host, startRMAN at the command prompt. You will now have an RMAN> prompt like this:
Recovery Manager: Release9.2.0.1.0 - Production
Copyright (c)1995, 2002, Oracle Corporation.  All rights reserved.
RMAN>
 
2. At the prompt, the current configuration can be displayed by typing this and pressing <Enter>:
show all;

You may get a reply similar to this:
RMANconfiguration parameters are:
CONFIGURE RETENTION POLICY TO REDUNDANCY1; # default
CONFIGURE BACKUP OPTIMIZATION OFF; #default
CONFIGURE DEFAULT DEVICE TYPE TO DISK; #default
CONFIGURE CONTROLFILE AUTOBACKUP OFF; #default
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISKTO '%F'; # default
CONFIGURE DEVICE TYPE DISK PARALLELISM 1; #default
CONFIGURE DATAFILE BACKUP COPIES FOR DEVICE TYPE DISK TO 1; #default
CONFIGURE ARCHIVELOG BACKUP COPIES FOR DEVICE TYPE DISK TO 1;# default
CONFIGURE MAXSETSIZE TO UNLIMITED; #default
 
3. If "CONFIGURE CONTROLFILEAUTOBACKUP OFF" is shown, it must be turned on. At the RMAN> prompt, type this:
CONFIGURE CONTROLFILEAUTOBACKUP ON; <Enter>
 
4. Now set the image name format to use "%F" so each image stored in the NetBackup catalog will have an easily identifiable date in the name. At the RMAN> prompt, type this:
SET CONFIGURE CONTROLFILEAUTOBACKUP FORMAT FOR DEVICE TYPE 'SBT_TAPE' TO '%F' ;<Enter>
 
5. Finally, set 'SBT_TAPE' as the default output device for Oracle AUTOBACKUP backups. This creates the connection to the NetBackup for Oracle agent instead of disk.
At the RMAN> prompt, type this:
SET CONFIGURE DEFAULT DEVICE TYPE TO'SBT_TAPE'; <Enter>
 
6. To manually test the control file backup to tape, at the RMAN> prompt, type this:
    backup current controlfile; <Enter>
Or
Run any database backup or script. When the backup completes, AUTOBACKUP will make a backup of the current control file.

*DONE WITH BACKUP


Understanding Oracle tapebackup images:

The NetBackup bplist command will produce output thatcan be used to review all retained backup history.
Note: The controlfile format using "%F" adds a readable date to the image name. For example"20050718" is July 18, 2005. RMAN increments "1" to the last number string (sequence) for each auto backup that is performed in a day.

Run bplist as the root user on the clienthost.

# bplist -t 4 -l -R / >bp.list.out
# catbp.list.out
-rw-------oracle    oracle        2097152 Jul 18 07:49/c-791235730-20050718-02
-rw-------oracle    oracle        2097152 Jul 18 07:48/cntrl_31_1_563960898
-rw-------oracle    oracle        2097152 Jul 18 07:47/c-791235730-20050718-01
-rw-------oracle    oracle         262144 Jul 18 07:45/al_29_1_563960680
-rw-------oracle    oracle        2097152 Jul 18 07:44/al_28_1_563960680
-rw-------oracle    oracle        2097152 Jul 18 07:43/c-791235730-20050718-00
-rw-------oracle    oracle      357826560 Jul 18 07:41/bk_26_1_563959504
-rw-------oracle    oracle      169607168 Jul 18 07:25/bk_25_1_563959504
-rw-------oracle    oracle        2097152 Jul 17 12:45/c-791235730-20050717-00
-rw-------oracle    oracle        2097152 Jul 17 12:41/0ngpojdq_1_1
-rw-------oracle    oracle        2097152 Jul 12 08:09/cntrl_14_1_563443748
-rw-------oracle    oracle         262144 Jul 12 08:07/al_13_1_563443618
-rw------- oracle    oracle      16777216 Jul 12 08:07 /al_12_1_563443618
-rw-------oracle    oracle      345505792 Jul 12 08:04/bk_11_1_563443402
-rw-------oracle    oracle      163053568 Jul 12 08:03/bk_9_1_563443307
-rw------- oracle    oracle      20971520 Jul 12 08:01 /bk_10_1_563443307

The same control file name format must be used for backup and restore. Here are the effects of two different name format configurations.

1. set controlfile autobackup format for device type sbt_tape to %F;
will produce a control file image named:
/c-791235730-20050718-02

2. set controlfile autobackup format for device typesbt_tape to ora_cf%F;
will produce a control file image named:
/ora_cfc-791235730-20050718-03


Restore
The RUN statement listed below is required. The commands will fail if run individually.

Also, while the DB is in NOMOUNT state, the configuration that is normally displayed with SHOWALL; will not be available to RMAN. Therefore, all configuration data must be typed into a script or run command.

The restore will take 2-3 minutes per search date to locate or pass before determining if an "autobackup" image is available. The default is seven days back starting today. It can be adjusted using MAXSEQ and MAXDAYS flags in the restore command.


Restore from "AUTOBACKUP" control file
Overview of Steps
1. Log onto the host as the Oracle user
2. Launch sqlplus as "sysdba"
3. Start Oracle in NOMOUNT
4. Launch RMAN
5. Connect to the target database
6. Locate and set the DBID
7. Run the appropriate configuration and restore string
8. Restore database

Restore Example (starting with Oracleshutdown):
# su -oracle
Sun Microsystems Inc.  SunOS 5.8       Generic February2000
*****************************************
$sqlplus "/ as sysdba"

SQL*Plus:Release 9.2.0.1.0 - Production on Sun Jul 17 12:49:222005

Copyright (c) 1982, 2002,Oracle Corporation.  All rightsreserved.

Connectedto:
Oracle9i Enterprise Edition Release 9.2.0.1.0 - Production
With the Partitioning, OLAP and Oracle Data Mining options
JServer Release 9.2.0.1.0 -Production

SQL> STARTUP NOMOUNT
ORACLE instance started.

Total System GlobalArea   43372604 bytes
FixedSize                   454716bytes
VariableSize              41943040bytes
DatabaseBuffers             819200bytes
RedoBuffers                 155648bytes
SQL>quit

$rman

Recovery Manager: Release9.2.0.1.0 - Production
Copyright (c)1995, 2002, Oracle Corporation.  All rights reserved.

RMAN> connect target
connected to target database:yourdb (not mounted)

RMAN> SETDBID=791234567        
executing command: SETDBID

***Notes for the restore command string:
Line 3 must be the same as the configuration used for the backup.
Line 4 opens a channel to NetBackup.
Line 5 must be configured with MAXSEQ and MAXDAYS to search to the appropriate date in the NetBackup catalog to locate the desired controlfile backup image.
* MAXSEQ defines the maximum sequence number (default starts with 256).
* MAXDAYS is the number of days from the current date the restore will search back to locate a control file auto backup (default of7, maximum of 366).
* SET UNTIL can also be used to direct the restore to the exact desired backup date.
Line 6 mounts the database so the control file data can be verified.
Line 7 [enter] means press the <Enter> key on the keyboard. Don't type [enter].

RMAN> run
2>{
3> set controlfile autobackup format for device type 'sbt_tape' to'%F';
4> allocate channel t1device type 'sbt_tape';
5> restore controlfile from autobackup MAXSEQ 5 MAXDAYS9;
6> mountdatabase;
7> }[enter]

executing command: SETCONTROLFILE AUTOBACKUPFORMAT

allocated channel:t1
channel t1: sid=12devtype=SBT_TAPE
channel t1: VERITAS NetBackup for Oracle - Release 4.5MP6(00000000)

Starting restore at01-AUG-05

channel t1: looking forautobackup on day: 20050801
channelt1: looking for autobackup on day:20050731
channel t1: looking forautobackup on day: 20050730
channelt1: looking for autobackup on day:20050729
channel t1: looking forautobackup on day: 20050728
channelt1: looking for autobackup on day:20050727
channel t1: looking forautobackup on day: 20050726
channelt1: looking for autobackup on day:20050725
channel t1: autobackupfound:c-791235730-20050725-02
channel t1:controlfile restore from autobackupcomplete
replicatingcontrolfile
inputfilename=/extra/u01/bobsdb/control01.ctl
outputfilename=/extra/u01/bobsdb/control02.ctl
outputfilename=/extra/u01/bobsdb/control03.ctl
Finishedrestore at 01-AUG-05

databasemounted
released channel:t1

RMAN>

*DONEWITH RESTORE

Continue restoring databases or tablespaces as needed using the history information in the control file.

Note: In Oracle 9.2 andlater, an alternative to the above restore procedure could be used by selecting and restoring a backup of a database and control file. The restore of the database will also restore the control file at the same time. Contact Oracle for details on this streamlined procedure.


 
 

 

Was this content helpful?