Recover database to a different host using legato & RMAN

Create the directories where datafiles will be restored. Set up the OFA structure on new host and copy the init.ora, config.ora files. Create the link in ORACLE_HOME/dbs directory for init.ora file. Add entry in /etc/oratab and /etc/ORACLE.PROFILE for the database. Change init.ora and config.ora to reflect new directories. If link is not created then startup_pfile parameter should be specified to give the location of parameter file to be used Create a password file for this new instance and specify password for internal. Create symbolic link for the old online redo log directory to point to new online redo log directory.
Rman scipt should be as folows for latest database backup restore.

Unix Shell Script:
#!/bin/ksh
today=`date +%y%m%d%H%M`
export ORACLE_SID=TEST804
export ORACLE_HOME=/oracle/app/oracle/product/8.0.4
export PATH=/users/oracle/bin:/oracle/app/oracle/bin:/oracle/app/oracle/product/8.0.4/bin:/usr/bin:/usr/bin/X11:/usr/dt/bin:/usr/local/bin:.
export NLS_LANG=american
export NLS_DATE_FORMAT='Mon DD YYYY HH24:MI:SS'

svrmgrl << EOF
connect internal
startup nomount restrict
EOF
rman target internal/sys rcvcat rman/rman@rcat1 cmdfile restore_test804.txt
svrmgrl << EOF
connect internal
shutdown
EOF

Following points need to be taken note of:

  • Make sure that your target database connection is to the new database. If is is connect to the database on HOST_A then the backup will be restored on HOST_A instead of HOST_C.
  • NLS_DATE_FORMAT is used for "set until command" to specify the time to which you want to go back
  • Symbolic link is needed because after restore is done and "OPEN RESETLOGS" needs to be done, at that time controlfile is still pointing to old locaion of online redo logs because "SWITCH DATAFILE" command works only on datafiles and not on redo logs. Thus "OPEN RESETLOGS" needs to have old directory accessible.
RMAN Script:
run {
set newname for datafile '/sales1/oradata/TEST804/TEST804_system01.dbf' to '/sm1/oradata/TEST804/TEST804_system01.dbf';
set archivelog destination to '/sm1/oradata/TEST804';
allocate channel t1 type 'sbt_tape'
parms 'ENV=(NSR_SERVER=host_b,NSR_CLIENT=host_a)';
allocate channel d2 type disk;
set until time 'Mar 18 1999 18:40:00';
restore controlfile to '/sm1/oradata/TEST804/control01.ctl';
replicate controlfile from '/sm1/oradata/TEST804/control01.ctl';
sql 'alter database mount';
restore (database);
switch datafile all;
}

Following points should be noted in this script:

  • set newname is used to give the new location for the datafiles. This command restores the file to new location but does not vhange the control file. Unlike EBU, for Rman each file needs to be specified separatly instead of a global change
  • set archivelog destination specifies the directory where archivelogs will be restored.
  • NSR_CLIENT and NSR_SERVER work as specified in earlier sections
  • NSR_DEBUG_FILE can be used to specify location and file name for a debug file to be generated. Moreover a log file sbtio.log is generated in ??/udump directory if any errors are encountered.
  • A channel to disk should be allocated if restored controlfile is being replicated to the locations specified by config.ora file.
  • switch datafile changes the control file to specify new location and filenames of restored datafiles.
  • Whenever a datafile is restored using "set newname" command a datafilecopy record is created in the catalog. This record will prevent you from restoring the same backup again. Thus after the restore is done identify the primary_key of these copies using

  • List copy of ‘filename’;

    Or

    Using following query on catalog database
    Select name,cdf_key
    from rc_datafile_copy where db_name=upper(‘&database_name’);

    And then remove it from the catalog using

    Change datafilecopy primary_key uncatalog;

Have a Oracle Question
Do you have an Oracle Question?

Oracle Books
Oracle Certification, Database Administration, SQL, Application, Programming Reference Books

Oracle Application
Oracle Application Hints and Tips

Oracle Home
Oracle Database, SQL, Application, Programming Tips

All the site contents are Copyright © www.erpgreat.com and the content authors. All rights reserved.
All product names are trademarks of their respective companies.
The site www.erpgreat.com is not affiliated with or endorsed by any company listed at this site.
Every effort is made to ensure the content integrity.  Information used on this site is at your own risk.
 The content on this site may not be reproduced or redistributed without the express written permission of
www.erpgreat.com or the content authors.