Restoring a Database from Veritas NetBackup

I wrote previously about integrating RMAN with Veritas NetBackup. The reason for doing so was so that I could easily verify that the backup went to tape and for recovery to be simpler. By integrating, I no longer needed to contact my NetBackup admin should I quickly need to recover my database. Also, as long as NetBackup was installed on multiple servers, I could easily clone/duplicate/restore my databases on any number of servers where it was installed. I am also using a recovery catalog to help simplify things. Without a recovery catalog, you will need to restore your control file which will have information about your backups, spfile, and previous control file backups prior to being backed up itself.

A couple of things to note. I only have 1 NetBackup policy of Oracle type assigned to this server by my Veritas NetBackup admin. Also, that policy is set to infinite retention so that RMAN controls when it wants to delete expired / obsolete backups by allocating a channel "for maintenance device type ‘SBT_TAPE’. A good practice is working with your NetBackup admin in order to configure your policy. You could also define multiple policies so he can more easily identify which backups to send offsite. The only problem with this approach, and it’s very minor at that, is that you will have to explicitly define your Oracle type NetBackup Policy when you do your backups.

To define them, you could do several things such as:

send 'NB_ORA_POLICY=some_policy';

or 

allocate channel t1 type 'sbt_tape' parms='SBT_LIBRARY=/usr/openv/netbackup/bin/libobk.so64.1, ENV=(NB_ORA_POLICY=<your_oracle_policy_name>, NB_ORA_SERV=<your_master_server_name>)';

or

CONFIGURE CHANNEL DEVICE TYPE 'SBT_TAPE' PARMS 'ENV=(NB_ORA_POLICY=<your_oracle_policy_name>, NB_ORA_SERV=<your_master_server_name>';

Now, if you did the last one, issue a "show all", it should be updated.

To more fully understand how NetBackup / Oracle integration worked, we turned on some tracing on the NetBackup side. What appears to happen is that Oracle engages the local NetBackup client via the libobk.so library and informs it that it wants to begin a backup. NetBackup then calls back to your server to connect and the backup begins. All NetBackup knows is it is backing up a file, which is the backupset. All the Oracle files are within the backup set. The backupset names should be unique. When you do a restore, Oracle then communicates with NetBackup and informs it that I need this "file". The file name can also be discovered by issuing the "list backup" command, which proves they are unique. Since there is only 1 filename, all NetBackup does is identify which tape the file(s) are on, loads the tape, finds the file, and sends them over the network back to RMAN which then opens the backup set and retrieves the file(s) it needs.

I created a test database in archive log mode. I then configured the default RMAN properties for that database to use ‘SBT_TAPE’ instead of DISK and enabled autobackup. I then backed up the database which then went to tape. Upon the successfull completion of the backup, I proceeded to use the ASMCMD command to delete this test database out of ASM. You can also do this restore without ASM or vice versa be renaming the datafile as you do the restore, however I just chose to use ASM for the database and will restore to it because there are a couple of added steps and I wanted this example to "scale" well : ). With no database, controlfiles, redologs, tempfiles, and spfile on disk, I tried a full restore of the database from tape.

Assuming you have a database in place, this is how you would configure RMAN and back it up via NetBackup.

First, we need to connect to our database and the recovery catalog. (If you are not using a recovery catalog, then you can skip this step).

testserver:/u01/app/oracle/product/10.2.0/agent10g/bin> export ORACLE_SID=rmantest
testserver:/u01/app/oracle/product/10.2.0/agent10g/bin> rman target / rcvcat rman/password@rmanrepository      

Recovery Manager: Release 10.2.0.4.0 - Production on Sun Jul 27 00:29:25 2008      

Copyright (c) 1982, 2007, Oracle.  All rights reserved.      

connected to target database: RMANTEST (DBID=3675070410)
connected to recovery catalog database     

RMAN> register database;      

database registered in recovery catalog
starting full resync of recovery catalog
full resync complete

Next, we will configure the RMAN defaults.

RMAN> show all;      

RMAN configuration parameters are:
CONFIGURE RETENTION POLICY TO REDUNDANCY 1; # 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 DISK TO '%F'; # default
CONFIGURE DEVICE TYPE DISK PARALLELISM 1 BACKUP TYPE TO BACKUPSET; # 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
CONFIGURE ENCRYPTION FOR DATABASE OFF; # default
CONFIGURE ENCRYPTION ALGORITHM 'AES128'; # default
CONFIGURE ARCHIVELOG DELETION POLICY TO NONE; # default
CONFIGURE SNAPSHOT CONTROLFILE NAME TO '/u01/app/oracle/product/10.2.0/dbs/snapcf_rmantest.f'; # default     

RMAN> CONFIGURE DEFAULT DEVICE TYPE TO 'SBT_TAPE';      

new RMAN configuration parameters:
CONFIGURE DEFAULT DEVICE TYPE TO 'SBT_TAPE';
new RMAN configuration parameters are successfully stored
starting full resync of recovery catalog
full resync complete      

RMAN> CONFIGURE CONTROLFILE AUTOBACKUP ON;      

new RMAN configuration parameters:
CONFIGURE CONTROLFILE AUTOBACKUP ON;
new RMAN configuration parameters are successfully stored
starting full resync of recovery catalog
full resync complete  

This next step is not necessary but makes it easier to identify when you issue a "list backup" command in RMAN.

RMAN> configure controlfile autobackup format for device type SBT_TAPE TO 'cf_%F';      

new RMAN configuration parameters:
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE 'SBT_TAPE' TO 'cf_%F';
new RMAN configuration parameters are successfully stored
starting full resync of recovery catalog
full resync complete  

Finally, we verify everything.

RMAN> show all;      

RMAN configuration parameters are:
CONFIGURE RETENTION POLICY TO REDUNDANCY 1; # default
CONFIGURE BACKUP OPTIMIZATION OFF; # default
CONFIGURE DEFAULT DEVICE TYPE TO 'SBT_TAPE';
CONFIGURE CONTROLFILE AUTOBACKUP ON;
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE SBT_TAPE TO 'cf_%F'; # default
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '%F'; # default
CONFIGURE DEVICE TYPE SBT_TAPE PARALLELISM 1 BACKUP TYPE TO BACKUPSET; # default
CONFIGURE DEVICE TYPE DISK PARALLELISM 1 BACKUP TYPE TO BACKUPSET; # default
CONFIGURE DATAFILE BACKUP COPIES FOR DEVICE TYPE SBT_TAPE TO 1; # default
CONFIGURE DATAFILE BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
CONFIGURE ARCHIVELOG BACKUP COPIES FOR DEVICE TYPE SBT_TAPE TO 1; # default
CONFIGURE ARCHIVELOG BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
CONFIGURE MAXSETSIZE TO UNLIMITED; # default
CONFIGURE ENCRYPTION FOR DATABASE OFF; # default
CONFIGURE ENCRYPTION ALGORITHM 'AES128'; # default
CONFIGURE ARCHIVELOG DELETION POLICY TO NONE; # default
CONFIGURE SNAPSHOT CONTROLFILE NAME TO '/u01/app/oracle/product/10.2.0/dbs/snapcf_rmantest.f'; # default  

Now let’s run a backup. I will include the archivelogs in the database backup. I will also include the spfile just in case even though it and the controlfile will be automatically backed up.

RMAN> backup database archivelog all delete input spfile;      

Starting backup at 27-Jul-2008-08:42:32
using channel ORA_SBT_TAPE_1
channel ORA_SBT_TAPE_1: starting full datafile backupset
channel ORA_SBT_TAPE_1: specifying datafile(s) in backupset
input datafile fno=00001 name=+DG1/rmantest/datafile/system.407.661134077
input datafile fno=00003 name=+DG1/rmantest/datafile/sysaux.406.661134077
input datafile fno=00005 name=+DG1/rmantest/datafile/example.403.661134169
input datafile fno=00002 name=+DG1/rmantest/datafile/undotbs1.396.661134077
input datafile fno=00004 name=+DG1/rmantest/datafile/users.398.661134077
channel ORA_SBT_TAPE_1: starting piece 1 at 27-Jul-2008-08:42:36
channel ORA_SBT_TAPE_1: finished piece 1 at 27-Jul-2008-08:45:21
piece handle=03jmh43s_1_1 tag=TAG20080727T084234 comment=API Version 2.0,MMS Version 5.0.0.0
channel ORA_SBT_TAPE_1: backup set complete, elapsed time: 00:02:45
channel ORA_SBT_TAPE_1: starting archive log backupset
channel ORA_SBT_TAPE_1: specifying archive log(s) in backup set
input archive log thread=1 sequence=2 recid=1 stamp=661134995
input archive log thread=1 sequence=3 recid=2 stamp=661135027
input archive log thread=1 sequence=4 recid=3 stamp=661135039
input archive log thread=1 sequence=5 recid=4 stamp=661135108
input archive log thread=1 sequence=6 recid=5 stamp=661135189
channel ORA_SBT_TAPE_1: starting piece 1 at 27-Jul-2008-08:45:22
channel ORA_SBT_TAPE_1: finished piece 1 at 27-Jul-2008-08:46:08
piece handle=04jmh491_1_1 tag=TAG20080727T084234 comment=API Version 2.0,MMS Version 5.0.0.0
channel ORA_SBT_TAPE_1: backup set complete, elapsed time: 00:00:47
channel ORA_SBT_TAPE_1: deleting archive log(s)
archive log filename=+DG1/rmantest/archivelog/2008_07_27/thread_1_seq_2.400.661134995 recid=1 stamp=661134995
archive log filename=+DG1/rmantest/archivelog/2008_07_27/thread_1_seq_3.399.661135027 recid=2 stamp=661135027
archive log filename=+DG1/rmantest/archivelog/2008_07_27/thread_1_seq_4.408.661135039 recid=3 stamp=661135039
archive log filename=+DG1/rmantest/archivelog/2008_07_27/thread_1_seq_5.416.661135109 recid=4 stamp=661135108
archive log filename=+DG1/rmantest/archivelog/2008_07_27/thread_1_seq_6.415.661135189 recid=5 stamp=661135189
channel ORA_SBT_TAPE_1: starting full datafile backupset
channel ORA_SBT_TAPE_1: specifying datafile(s) in backupset
including current SPFILE in backupset
channel ORA_SBT_TAPE_1: starting piece 1 at 27-Jul-2008-08:46:09
channel ORA_SBT_TAPE_1: finished piece 1 at 27-Jul-2008-08:46:54
piece handle=05jmh4ag_1_1 tag=TAG20080727T084234 comment=API Version 2.0,MMS Version 5.0.0.0
channel ORA_SBT_TAPE_1: backup set complete, elapsed time: 00:00:46
Finished backup at 27-Jul-2008-08:46:54      

Starting Control File and SPFILE Autobackup at 27-Jul-2008-08:46:54
piece handle=cf_c-3675070410-20080727-01 comment=API Version 2.0,MMS Version 5.0.0.0
Finished Control File and SPFILE Autobackup at 27-Jul-2008-08:48:01      

RMAN> exit

Now we will annihilate the database on the server. :) We begin by shutting the DB down. (NOTE: you could have also entered this command within the RMAN console)

testserver:/u01/app/oracle/product/10.2.0/agent10g/bin> echo $ORACLE_SID
rmantest
testserver:/u01/app/oracle/product/10.2.0/agent10g/bin> sqlplus / as sysdba      

SQL*Plus: Release 10.2.0.4.0 - Production on Sun Jul 27 09:01:30 2008      

Copyright (c) 1982, 2007, Oracle.  All Rights Reserved.      

Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options      

SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> exit
Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

We now need to delete the database files / folders. The instructions for ASM are below. If a filesystem, it should be very simple to delete.

testserver:/u01/app/oracle/product/10.2.0/agent10g/bin> export ORACLE_SID=+ASM
testserver:/u01/app/oracle/product/10.2.0/agent10g/bin> asmcmd -p      

ASMCMD [+] > cd DG1
ASMCMD [+DG1] > ls
rmantest/
ASMCMD [+DG1/rmantest] > rm -r rmantest
You may delete multiple files and/or directories.
Are you sure? (y/n) y
ASMCMD [+DG1] > cd +DG2
ASMCMD [+DG2] > rm -r rmantest
You may delete multiple files and/or directories.
Are you sure? (y/n) y
ASMCMD [+DG2/] > exit

Now let’s assume that you had rebuilt ASM and installed the ORACLE 10g binaries and patched to the same version or greater than where your DB compatibility mode was, or you can assume that the DB just crashed and you are recovering it. I am assuming that ASM and the binaries are fine and all the prereqs have been done but that my directory for my database in ASM is not there.

I will connect to ASM and mkdir for my database in the first diskgroup so that I can restore my spfile or I will get an error that the rmantest directory does not exist.Our $ORACLE_SID already equals +ASM (It would be +ASM1 etc… in a RAC environment)

testserver:/export/home/oracle> asmcmd -p
ASMCMD [+] > cd DG1
ASMCMD [+DG1] > mkdir rmantest
ASMCMD [+DG1] > exit

Next, we need to connect to RMAN and start the database in nomount mode. You will need a dummy pfile to initially get the processes started. Here is the example of mine below. Remember, all you care about is getting the instance started in nomount mode so you can restore your original spfile to ASM. Once you do that, you will shutdown the instance and restart with the correct spfile in nomount mode.

*.aq_tm_processes=0
*.background_dump_dest='/u01/app/oracle/admin/rmantesting/bdump'
*.compatible='10.2.0.4.0'
*.control_files='+DG1/rmantesting/controlfile/current.320.644796453','+DG2/rmantesting/controlfile/current.257.644796179'
*.core_dump_dest='/u01/app/oracle/admin/rmantesting/cdump'
*.db_block_size=8192
*.db_domain=''
*.db_file_multiblock_read_count=32
*.db_name='rmantest'
*.db_recovery_file_dest_size=4G
*.db_recovery_file_dest='+DG2'
*.dispatchers='(PROTOCOL=TCP) (SERVICE=rmantestingXDB)'
*.job_queue_processes=0
*.log_archive_format='%t_%s_%r.dbf'
*.nls_length_semantics='BYTE'
*.open_cursors=300
*.optimizer_dynamic_sampling=3
*.parallel_max_servers=100
*.pga_aggregate_target=838860800
*.processes=1000
*.remote_login_passwordfile='EXCLUSIVE'
*.resource_manager_plan=''
*.session_cached_cursors=100
*.sessions=105
*.sga_max_size=800M
*.sga_target=400M
*.star_transformation_enabled='TRUE'
*.undo_management='AUTO'
*.undo_retention=900
*.user_dump_dest='/u01/app/oracle/admin/rmantesting/udump'

Now we need to find our DBID from the RMAN catalog by directly logging into sqlplus and executing the following query. (NOTE: you will see all the DB’s registered in your recovery catalog)

testserver:/export/home/oracle> sqlplus rman/password@rmanrepository      

SQL*Plus: Release 10.2.0.4.0 - Production on Sun Jul 27 09:02:50 2008      

Copyright (c) 1982, 2007, Oracle.  All Rights Reserved.      

Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - 64bit Production
With the Partitioning, Real Application Clusters, OLAP and Data Mining options      

SQL> select distinct db_id, db_name
from db a, dbinc b
where a.db_key=b.db_key;
  2    3
     DB_ID DB_NAME
---------- --------
3675070410 RMANTEST      

1 row selected.      

SQL> exit
Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - 64bit Production
With the Partitioning, Real Application Clusters, OLAP and Data Mining options

We now have all the information we need to do a restore, so we now execute RMAN.

testserver:/u01/app/oracle/product/10.2.0/agent10g/bin> export ORACLE_SID=rmantest
testserver:/u01/app/oracle/product/10.2.0/agent10g/bin> rman target / rcvcat rman/password@rmanrepository      

Recovery Manager: Release 10.2.0.4.0 - Production on Sun Jul 27 09:29:51 2008      

Copyright (c) 1982, 2007, Oracle.  All rights reserved.      

connected to target database (not started)
connected to recovery catalog database     

RMAN> set dbid=3675070410      

executing command: SET DBID
database name is "RMANTEST" and DBID is 3675070410      

RMAN> startup pfile='/export/home/oracle/dummypfile.ora' nomount;      

Oracle instance started      

Total System Global Area     838860800 bytes      

Fixed Size                     2044328 bytes
Variable Size                566234712 bytes
Database Buffers             264241152 bytes
Redo Buffers                   6340608 bytes      

RMAN>

Now we will restore our spfile, shutdown the instance, and restart with the correct spfile in nomount mode. We will then restore our controfile and mount the database.

RMAN> restore spfile;      

Starting restore at 27-Jul-2008-09:51:58
using channel ORA_SBT_TAPE_1
using channel ORA_DISK_1      

channel ORA_SBT_TAPE_1: starting datafile backupset restore
channel ORA_SBT_TAPE_1: restoring SPFILE
output filename=+DG1/rmantest/spfilermantest.ora
channel ORA_SBT_TAPE_1: reading from backup piece cf_c-3675070410-20080727-01
channel ORA_SBT_TAPE_1: restored backup piece 1
piece handle=cf_c-3675070410-20080727-01 tag=TAG20080727T084705
channel ORA_SBT_TAPE_1: restore complete, elapsed time: 00:02:27
Finished restore at 27-Jul-2008-09:54:33      

RMAN> shutdown immediate;      

Oracle instance shut down      

RMAN> startup nomount      

connected to target database (not started)
Oracle instance started      

Total System Global Area     838860800 bytes      

Fixed Size                     2044264 bytes
Variable Size                213913240 bytes
Database Buffers             616562688 bytes
Redo Buffers                   6340608 bytes      

RMAN> restore controlfile;      

Starting restore at 27-Jul-2008-09:55:30
allocated channel: ORA_SBT_TAPE_1
channel ORA_SBT_TAPE_1: sid=156 devtype=SBT_TAPE
channel ORA_SBT_TAPE_1: VERITAS NetBackup for Oracle - Release 5.1 (2006110403)
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=155 devtype=DISK      

channel ORA_SBT_TAPE_1: starting datafile backupset restore
channel ORA_SBT_TAPE_1: restoring control file
channel ORA_SBT_TAPE_1: reading from backup piece cf_c-3675070410-20080727-01
channel ORA_SBT_TAPE_1: restored backup piece 1
piece handle=cf_c-3675070410-20080727-01 tag=TAG20080727T084705
channel ORA_SBT_TAPE_1: restore complete, elapsed time: 00:00:53
output filename=+DG1/rmantest/controlfile/current.397.661168569
output filename=+DG2/rmantest/controlfile/current.377.661168573
Finished restore at 27-Jul-2008-09:56:33      

RMAN> alter database mount;      

database mounted
released channel: ORA_SBT_TAPE_1
released channel: ORA_DISK_1

We need to list our backups and find the greatest SCN # we have available (which will only be on tape in this example).

RMAN> list backup;      

List of Backup Sets
===================      

BS Key  Type LV Size       Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ --------------------
1911719 Full    624.00M    SBT_TAPE    00:47:11     27-Jul-2008-01:24:13
        BP Key: 1911720   Status: AVAILABLE  Compressed: NO  Tag: TAG20080727T003701
        Handle: 01jmg7le_1_1   Media:
  List of Datafiles in backup set 1911719
  File LV Type Ckp SCN    Ckp Time             Name
  ---- -- ---- ---------- -------------------- ----
  1       Full 578112     27-Jul-2008-00:37:02 +DG1/rmantest/datafile/system.407.661134077
  2       Full 578112     27-Jul-2008-00:37:02 +DG1/rmantest/datafile/undotbs1.396.661134077
  3       Full 578112     27-Jul-2008-00:37:02 +DG1/rmantest/datafile/sysaux.406.661134077
  4       Full 578112     27-Jul-2008-00:37:02 +DG1/rmantest/datafile/users.398.661134077
  5       Full 578112     27-Jul-2008-00:37:02 +DG1/rmantest/datafile/example.403.661134169      

BS Key  Type LV Size       Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ --------------------
1913346 Full    628.25M    SBT_TAPE    00:02:43     27-Jul-2008-08:45:19
        BP Key: 1913354   Status: AVAILABLE  Compressed: NO  Tag: TAG20080727T084234
        Handle: 03jmh43s_1_1   Media:
  List of Datafiles in backup set 1913346
  File LV Type Ckp SCN    Ckp Time             Name
  ---- -- ---- ---------- -------------------- ----
  1       Full 592007     27-Jul-2008-08:42:36 +DG1/rmantest/datafile/system.407.661134077
  2       Full 592007     27-Jul-2008-08:42:36 +DG1/rmantest/datafile/undotbs1.396.661134077
  3       Full 592007     27-Jul-2008-08:42:36 +DG1/rmantest/datafile/sysaux.406.661134077
  4       Full 592007     27-Jul-2008-08:42:36 +DG1/rmantest/datafile/users.398.661134077
  5       Full 592007     27-Jul-2008-08:42:36 +DG1/rmantest/datafile/example.403.661134169      

BS Key  Size       Device Type Elapsed Time Completion Time
------- ---------- ----------- ------------ --------------------
1913347 10.25M     SBT_TAPE    00:00:43     27-Jul-2008-08:46:04
        BP Key: 1913355   Status: AVAILABLE  Compressed: NO  Tag: TAG20080727T084234
        Handle: 04jmh491_1_1   Media:      

  List of Archived Logs in backup set 1913347
  Thrd Seq     Low SCN    Low Time             Next SCN   Next Time
  ---- ------- ---------- -------------------- ---------- ---------
  1    2       574463     27-Jul-2008-00:24:19 578093     27-Jul-2008-00:36:34
  1    3       578093     27-Jul-2008-00:36:34 578116     27-Jul-2008-00:37:07
  1    4       578116     27-Jul-2008-00:37:07 578121     27-Jul-2008-00:37:19
  1    5       578121     27-Jul-2008-00:37:19 578145     27-Jul-2008-00:38:28
  1    6       578145     27-Jul-2008-00:38:28 578181     27-Jul-2008-00:39:49      

BS Key  Type LV Size       Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ --------------------
1913348 Full    256.00K    SBT_TAPE    00:00:41     27-Jul-2008-08:46:49
        BP Key: 1913356   Status: AVAILABLE  Compressed: NO  Tag: TAG20080727T084234
        Handle: 05jmh4ag_1_1   Media:
  SPFILE Included: Modification time: 27-Jul-2008-00:25:29      

BS Key  Type LV Size       Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ --------------------
1913374 Full    7.00M      SBT_TAPE    00:00:47     27-Jul-2008-08:47:52
        BP Key: 1913376   Status: AVAILABLE  Compressed: NO  Tag: TAG20080727T084705
        Handle: cf_c-3675070410-20080727-01   Media:
  Control File Included: Ckp SCN: 592110       Ckp time: 27-Jul-2008-08:47:05
  SPFILE Included: Modification time: 27-Jul-2008-00:25:29

We see an SCN of 592007 in backup set 1913346. All of our archivelogs appear to be less than this, so this is the number we will use.

RMAN> restore database until scn 592007;      

Starting restore at 27-Jul-2008-09:59:50
Starting implicit crosscheck backup at 27-Jul-2008-09:59:50
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=155 devtype=DISK
Finished implicit crosscheck backup at 27-Jul-2008-09:59:52      

Starting implicit crosscheck copy at 27-Jul-2008-09:59:52
using channel ORA_DISK_1
Finished implicit crosscheck copy at 27-Jul-2008-09:59:52      

searching for all files in the recovery area
cataloging files...
no files cataloged      

allocated channel: ORA_SBT_TAPE_1
channel ORA_SBT_TAPE_1: sid=156 devtype=SBT_TAPE
channel ORA_SBT_TAPE_1: VERITAS NetBackup for Oracle - Release 5.1 (2006110403)
using channel ORA_DISK_1      

channel ORA_SBT_TAPE_1: starting datafile backupset restore
channel ORA_SBT_TAPE_1: specifying datafile(s) to restore from backup set
restoring datafile 00001 to +DG1/rmantest/datafile/system.407.661134077
restoring datafile 00002 to +DG1/rmantest/datafile/undotbs1.396.661134077
restoring datafile 00003 to +DG1/rmantest/datafile/sysaux.406.661134077
restoring datafile 00004 to +DG1/rmantest/datafile/users.398.661134077
restoring datafile 00005 to +DG1/rmantest/datafile/example.403.661134169
channel ORA_SBT_TAPE_1: reading from backup piece 03jmh43s_1_1
channel ORA_SBT_TAPE_1: restored backup piece 1
piece handle=03jmh43s_1_1 tag=TAG20080727T084234
channel ORA_SBT_TAPE_1: restore complete, elapsed time: 00:02:26
Finished restore at 27-Jul-2008-10:02:34      

RMAN> recover database;      

Starting recover at 27-Jul-2008-10:07:17
using channel ORA_SBT_TAPE_1
using channel ORA_DISK_1      

starting media recovery      

archive log thread 1 sequence 7 is already on disk as file +DG2/rmantest/onlinelog/group_1.873.661134159
archive log filename=+DG2/rmantest/onlinelog/group_1.873.661134159 thread=1 sequence=7
media recovery complete, elapsed time: 00:00:01
Finished recover at 27-Jul-2008-10:07:37     

RMAN>

Now we must open with the resetlogs option. This will create a new incarnation of the database and the controlfile and recovery catalog will be updated and resynced.

RMAN> alter database open resetlogs;      

database opened
new incarnation of database registered in recovery catalog
starting full resync of recovery catalog
full resync complete      

RMAN> exit

Now let’s verify we can login to the database.

testserver:/export/home/oracle> export ORACLE_SID=rmantest
testserver:/export/home/oracle> sqlplus / as sysdba      

SQL*Plus: Release 10.2.0.4.0 - Production on Sun Jul 27 10:09:06 2008      

Copyright (c) 1982, 2007, Oracle.  All Rights Reserved.      

Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options      

SQL>

Now just verify via ASMCMD that your TEMPFILE and UNDO Tablespaces are there. Mine were.

12 Comments »

  1. Log Buffer #108: A Carnival of the Vanities for DBAs said,

    August 1, 2008 @ 9:04 am

    [...] Oracle Rant, Thomas Roach has a thorough howto on restoring a database from Veritas NetBackup, a follow-up to his popular piece from May on RMAN and Veritas NetBackup [...]

  2. Dennis said,

    September 5, 2008 @ 8:06 pm

    How to restore database, datafile, and archivelog to the different server ?.

    Let’s say we have myprod db on sun01 and rman repository rmanrep is on sun02.

    sun01 is crashed, so we want to restore the database myprod to sun03. Both sun01 and sun03 can access sun02 and master server.

    Thanks

  3. Thomas Roach said,

    September 6, 2008 @ 2:50 am

    All you do is set your Oracle Home and instead of just issuing an rman target /, you issue an rman target / rcvcat rmanuser/password@catdb. Before doing this, make sure Veritas NB is installed and configured. It is linked with Oracle, and then startup a dummy instance in nomount mode.

    You may have to set your DBID (see how to do it above) but it should be that easy. Restore your spfile, and then startup with the spfile. Then you need to just restore. It will have the same DBID and everything as your primary DB. You can then run your backups from here. You can even duplicate the DB there if you’d like.

  4. Dennis said,

    September 6, 2008 @ 11:35 am

    Hi Thomas. thanks for your explain. Do I have to set parameter NB_ORA_CLIENT=sun01 when I restore db on sun03? For dataguard, how to restore archivelog to the standby server instead of the primary server?

    Dennis

  5. Thomas Roach said,

    September 6, 2008 @ 12:20 pm

    If you have only one NetBackup policy of “ORACLE TYPE” for that server (setup on the NB side) then no you don’t. If you have more then 1, then yes you do because it’s ambigious as to which one you want to use.

    You want to restore archive logs to the standby for your DG? You want to catch up your backups? Well the DBID’s are the same as long as you use an RMAN Recovery Catalog so you should be able to restore them there as long as everything is accesible (the NetBackup software and the tapes where the archivelogs are). If you have a lot of catching up to do, then just do an RMAN incremental backup as of a certain SCN, recreate a control file for standby (both on the primary) and ship across the network or use NB to restore on the standby.

  6. Jocelyn said,

    March 31, 2009 @ 10:38 am

    Hi Thomas,

    I am new to rman backups and am having a problem with restoring. Is it possible to resync the rman catalog with netbackup? The rman catalog sees only the first copy of backup, which has since been overwritten. The second copy exists in Netbackup but rman does not know about it. Is there a fix for this issue?

    Regards,
    Jocelyn

  7. Thomas Roach said,

    March 31, 2009 @ 10:45 am

    Jocelyn,

    You will have to manually copy the backupsets off to disk and then catalog them.

    Here is a thread with more details of how to do this.

    http://forums.oracle.com/forums/thread.jspa?threadID=394064

  8. Jocelyn said,

    March 31, 2009 @ 11:16 am

    Thanks!

  9. Jocelyn said,

    April 3, 2009 @ 10:30 am

    Hi Thomas, I was hoping you might have more insight for me. As I manually tar a restore of the backup images to disk, the files show up empty on disk

    ]$: /usr/openv/netbackup/bin/tar -x -v -p -f /tmp/tape -b 512
    Hmm, this doesn’t look like a tar archive.
    Skipping to next file header…

    Skipping unknown extras header @@ExTeNdEd_Data.
    /bk_uacjvsabq_s11596_p1_t670968186
    Removing leading / from absolute path names in the archive.
    Unknown file type ‘(‘ for bk_uacjvsabq_s11596_p1_t670968186, extracted as normal file
    Skipping to next file header…

  10. Thomas Roach said,

    September 3, 2010 @ 3:36 pm

    Dennis, actually you do need to set that parameter. it is called a redirected restore. You can find more here.

    http://seer.entsupport.symantec.com/docs/278894.htm

    I got it confused with policy. My bad.

  11. Thomas Roach said,

    September 3, 2010 @ 3:47 pm

    Jocelyn, it is an Oracle type. I thought you could do this but apparently you can’t. Here is some more information on Oracle-L where I asked a question just like yours and got great responses!

    http://www.freelists.org/post/oracle-l/Catalog-RMAN-backups-on-Tape

    and here

    http://erpondb.blogspot.com/2008/09/catalog-rman-backuppieces.html

    In the first link, if you look through the list, you can find out how to list the pieces and then catalog them in RMAN so they can be pulled (see the 2nd link).

  12. Thomas Roach said,

    September 3, 2010 @ 3:48 pm

    Actually this is a better post.

    http://oracleprof.blogspot.com/2010/02/rman-and-sbttape-backup-pieces-how-to.html

RSS feed for comments on this post · TrackBack URI

Leave a Comment