Previous Topic: Recovery Manager (RMAN) and Restoring a Database to an Alternate ServerNext Topic: Restore Using Command Line


Restore a Database to Another Host Using RMAN

You can restore a database to another host using RMAN.

To restore a database to another host using RMAN

  1. Enter the following commands to obtain the db_id value (database ID) of the database you want to restore from the RMAN catalog:
    sqlplus <rman user>/<rman password>@<rman service>
    SQL> select db_key, db_id, bs_key, recid, stamp, backup_type, start_time, status from rc_backup_set;
    
  2. Identify the db_id value corresponding to the database you want to restore.
  3. Enter the following command to determine the file number and location of each data file in the source database:
    SVRMGR> select file#, name from v$data file;
    
  4. Copy the init<$ORACLE_SID>.ora file from $ORACLE_HOME/dbs on <host1> to <host2>.
  5. Edit the $ORACLE_HOME/dbs/init<$ORACLE_SID>.ora and adjust all paths to reflect the new directory structure on <host2>.
  6. Perform SQL*Net configure to ensure that the RMAN catalog is visible from both databases installed on <host1> and <host2>.
  7. Set up the Oracle password file on <host2> by entering the following command:
    orapwd file=$ORACLE_HOME/dbs/orapw$ORACLE_SID password=kernel.
    
  8. Enter the following command to start the destination database with the nomount option:
    SVRMGR> startup nomount pfile=$ORACLE_HOME/dbs/init<$ORACLE_SID>.ora
    
  9. Enter the following commands to restore the control file:

    Note: You will need the db_id you obtained in Step 2.

    rman rcvcat <rman username>/<rman password>@<rman service>
    
    RMAN> set dbid=<source database db_id value>
    
    RMAN> connect target <username>/<password>;
    
    RMAN> run {
    
    RMAN> allocate channel dev1 type 'sbt_tape';
    
    RMAN> restore controlfile;
    
    RMAN> release channel dev1;
    
    RMAN> }
    
  10. Enter the following command to mount the destination database:
    SVRMGR> alter database mount;
    
  11. Determine the new locations for each data file within the RMAN script using the locations you determined in Step 3.
  12. Enter the following commands to restore the database using the new locations you determined in Step 11:
    rman target <username>/<password> rcvcat <rman username>/<rman password>@<rman service>
    
    RMAN> run {
    
    RMAN> allocate channel dev1 type 'sbt_tape';
    
    RMAN> set newname for data file 1 to '<new path>'
    
    RMAN> set newname for data file 2 to '<new path>'
    
    ...
    
    RMAN> restore database;
    
    RMAN> switch data file all;
    
    RMAN> release channel dev1;
    
  13. Enter the following command to recover the database using the restored control files:
    SVRMGR> recover database using backup controlfile until cancel;
    
  14. Enter the following command to open the database using the resetlogs option:
    SVRMGR> alter database open resetlogs;
    
  15. If the error ORA-00344: unable to re-create online log %s occurs:
    1. Enter the following commands to rename each online redo log:
      SVRMGR> alter database rename file <online redo log #1 path> 
      to <online redo log #1 new path>;
      ...
      SVRMGR> alter database rename file <online redo log #n path> 
      to <onlne redo log #n new path>;
      
    2. Enter the following command to open the database:
      SVRMGR> alter database open resetlogs;