Problem :
I was needed to do the production database restore in order to recover the lost data from production database. The data was lost from few tables only so I decided to restore production database from backup to another host. The Oracle is configured with Netbackup.
Solution :
As i said, We have Netbackup configured with Oracle. We backup the database to disk first and then push the backup pieces to tapes using Symantec’s Netbackup for Oracle.
Restoring the production backup on new host is called Indirect Restore in the world of Netbackup.
There are few requirements which need to be met before the actual database restore with RMAN can be started.
- The Oracle binary version and platform must be same on both original server and new server.
- The Netbackup Client must be installed on the client where you want to restore the database.
- You need to set up the environment exactly same as the source else the restore would fail. You can use RMAN’s set newname command if you have different directory structure on new host.
- Make sure you know the Original machine name where the backup was taken, the master Netbackup server name and Netbackup policy name for the database.
- RMAN catalog should be installed and the database which needs to restore must be registered with the RMAN catalog.This is not mandatory but it will make the restore process much more easier if you have it.
Assuming that the tapes which holds the backup are loaded into the robotic library.
Netbackup also maintains the backup information in its catalog which is stored on the master netbackup server. You can always query master netbackup server’s catalog using bplist command if you want to find the backup information from netbackup’s catalog.
|
1 |
/opt/openv/netbackup/bin/bplist -C <original database host> -l -t 4 -s 03/22/2010 -e 04/01/2010 -R / |
Now we can proceed with the restore process but before we can restore the database, we need to create pfile for new database and start the instance in nomount mode.
- Create pfile from production’s spfile and copy it over to new server’s $ORACLE_HOME/dbs folder.
On Production,
|
1 2 3 4 5 |
$sqlplus / as sysdba SQL>create pfile=’/tmp/initPRD.ora’ from spfile; $scp /tmp/initPRD.ora new-server:$ORACLE_HOME/dbs |
- Set the environment variables on new server and start the instance with pfile copied over. Please make sure that all the file paths mentioned in pfile are valid.
On new server,
|
1 2 3 4 |
$export ORACLE_SID=PRD $export ORACLE_HOME=/u01/app/oracle/product/11.2.0/db_1 $sqlplus / as sysdba SQL>startup nomount pfile=’$ORACLE_HOME/initPRD.ora’ |
- Restore the control file.
We need to find the control file’s backup piece before we can restore it. We can use bplist command to find the backup piece name.
For example,
|
1 |
$ /opt/openv/netbackup/bin/bplist -C prod_server -l -t 4 -s 03/22/2010 -e 04/01/2010 -R / |
So once the backup piece has been identified we can proceed with the control file restore.
On new server,
|
1 |
$rman rman/password@rman_catalog target / |
|
1 |
RMAN> set dbid=10000000 <-- Change this to correct DB ID of the production database. |
|
1 2 3 4 5 |
RMAN>run { ALLOCATE CHANNEL CH00 TYPE 'SBT_TAPE'; SEND 'NB_ORA_SERV=<Master Netbackup Server>,NB_ORA_POLICY=<RMAN backup Policy>,NB_ORA_CLIENT=<original backup host>'; restore controlfile to ‘/tmp/control.ctl’ from ‘PRD_CNTRL_c-0000000000-20100322-07’; } |
Once control file is restored, please copy control file to the location mentioned in the pfile.
For example,
|
1 |
$cp /tmp/control.ctl /u01/app/oracle/oradata/PRD/control01.ctl |
You can mount the database now.
|
1 2 3 |
$sqlplus / as sysdba SQL>alter database mount; |
NB_ORA_SERV = Netbackup master server name.
NB_ORA_POLICY = Netbackup Database backup policy name.
NB_ORA_CLIENT = Original Backup host name.
- Restore the database and archive logs.
On new server,
|
1 2 3 4 5 6 7 8 9 10 |
$rman target / run { ALLOCATE CHANNEL CH00 TYPE 'SBT_TAPE'; ALLOCATE CHANNEL CH01 TYPE 'SBT_TAPE'; SEND 'NB_ORA_SERV=<Master Netbackup Server>,NB_ORA_POLICY=<RMAN backup Policy>,NB_ORA_CLIENT=<original backup host>'; sql 'alter session set NLS_DATE_FORMAT="YYYY-MM-dd HH24:MI:SS"'; set until time '2010-03-23 12:00:00'; restore database; restore archivelog all; } |
- Recover the database.
On new server,
|
1 2 3 4 5 6 7 8 9 |
$rman target / run { ALLOCATE CHANNEL CH00 TYPE 'SBT_TAPE'; ALLOCATE CHANNEL CH01 TYPE 'SBT_TAPE'; SEND 'NB_ORA_SERV=<Master Netbackup Server>,NB_ORA_POLICY=<RMAN backup Policy>,NB_ORA_CLIENT=<original backup host>'; sql 'alter session set NLS_DATE_FORMAT="YYYY-MM-dd HH24:MI:SS"'; set until time '2010-03-23 12:00:00'; recover database; } |
- Open the database.
On new server,
|
1 2 |
$sqlplus / as sysdba SQL>alter database open resetlogs; |
- LOGS
The Netbackup client logs can be found in the following directory.
|
1 |
/opt/openv/netbackup/logs/user_ops/dbext/logs |