Restoring to a New Database Host

If there’s a site failure and your database servers are down, you can use the backups in the cloud to restore to a new host. The following example shows how to restore backups from Oracle Database Backup Cloud Service to a new host.

Note:

If you want to restore the database to an Oracle Database Cloud Service database deployment (non-Virtual Image), see Creating a Database Deployment Using a Cloud Backup in Using Oracle Database Cloud Service. Otherwise, use the following steps to restore to a new host. You would also use these steps to restore to Oracle Database Cloud Service - Virtual Image database deployments.

To perform the steps in this example, the new host must have the following:

  • Internet connectivity to connect to Oracle Database Backup Cloud Service

  • A compatible operating system with the same endian format as the source host

  • The same version of Oracle Database software as the source host

    If the new host has a higher version of Oracle software, ensure that there is a supported upgrade path between the Oracle Database version on the source host and the destination host. Then, perform the steps required to upgrade the destination database after the RMAN restore.

You must also know the following:

  • DBID of the source database

  • Password used to encrypt the backup if password-based encryption was used

  • TDE encryption wallet from the source database if TDE encryption was used

To restore from a cloud backup stored using Oracle Cloud Infrastructure or Oracle Cloud Infrastructure Classic to a new host:

  1. Install the Oracle Database Cloud Backup Module for OCI or Oracle Database Cloud Backup Module for OCI Classic on the new host using the same subscription credentials and custom container (if any) used for the backup. For information about installing the module, see Downloading and Installing the Oracle Database Cloud Backup Module for OCI or Downloading and Installing the Oracle Database Cloud Backup Module for OCI Classic.

    For example, with Oracle Cloud Infrastructure Classic, the service name (-serviceName), identity domain (-identityDomain), user name (-opcId), password (-opcPass), and container name (-container), if you used a custom container, must be the same. With Oracle Cloud Infrastructure, the tenancy OCID (-tOCID), user OCID (-uOCID), and bucket (-bucket), if you used a custom bucket, must be the same.

  2. On the new host, connect to Recovery Manager (RMAN), set the decryption password, set the DBID, and restore the SPFILE.

    For example:

    rman target /
    RMAN> STARTUP NOMOUNT;
    RMAN> SET DECRYPTION IDENTIFIED BY 'my_bkup_pwd';
    RMAN> SET DBID=3389098001;
    RMAN> RUN {
    ALLOCATE CHANNEL t1 DEVICE TYPE sbt PARMS 'SBT_LIBRARY=libopc.so ENV=(OPC_PFILE=/u01/app/oracle/product/12.1.0/dbhome_1/dbs/opcDUP.ora)';
    RESTORE SPFILE TO PFILE '/u01/app/oracle/product/12.1.0/dbhome_1/dbs/initDUP.ora' FROM AUTOBACKUP;
    }

    The same password used to encrypt the backup must be used for restore and recovery operations.

    If the TDE wallet was used to encrypt the backup, the wallet must be copied to the new host and the wallet location must be set in the sqlnet.ora file before restoration is started. For details, see relevant information in My Oracle Support Doc ID 1560327.1 at http://support.oracle.com. Also, use SET ENCRYPTION ON; instead of SET DECRYPTION IDENTIFIED BY 'my_bkup_pwd'; as shown in the example above.

  3. Edit the PFILE to reflect the new host, changing control file locations, create and recovery file destinations, and audit file destinations. For example, change the *_dest parameters so all destinations are correct, change the control_files parameter, and so on. If necessary, create the relevant directories on the new host.

  4. Shut down the target database instance on the new host, restart the instance to the NOMOUNT state, restore the control file, and mount the database.

    For example:

    RMAN> SHUTDOWN IMMEDIATE;
    RMAN> STARTUP NOMOUNT;
    RMAN> RUN {
    ALLOCATE CHANNEL t1 DEVICE TYPE sbt PARMS 'SBT_LIBRARY=libopc.so ENV=(OPC_PFILE=/u01/app/oracle/product/12.1.0/dbhome_1/dbs/opcDUP.ora)';
    RESTORE CONTROLFILE FROM AUTOBACKUP;
    }
    RMAN> ALTER DATABASE MOUNT; 
  5. If necessary, use the SET NEWNAMES command to define a new location for the restored data file (Oracle Database 10g and later) or database (Oracle Database 11g and later), and then start the restoration and recovery.

    For example:

    RMAN> RUN {
    SET NEWNAME FOR DATABASE TO '/u02/app/oracle/oradata/DUP/%U';
    ALLOCATE CHANNEL t1 DEVICE TYPE sbt PARMS 'SBT_LIBRARY=libopc.so ENV=(OPC_PFILE=/u01/app/oracle/product/12.1.0/dbhome_1/dbs/opcDUP.ora)';
    ALLOCATE CHANNEL t2 DEVICE TYPE sbt PARMS 'SBT_LIBRARY=libopc.so ENV=(OPC_PFILE=/u01/app/oracle/product/12.1.0/dbhome_1/dbs/opcDUP.ora)';
    ALLOCATE CHANNEL t3 DEVICE TYPE sbt PARMS 'SBT_LIBRARY=libopc.so ENV=(OPC_PFILE=/u01/app/oracle/product/12.1.0/dbhome_1/dbs/opcDUP.ora)';
    RESTORE DATABASE;
    SWITCH DATAFILE ALL;
    SQL "ALTER DATABASE RENAME FILE ''+DATA/ASMDEMO1/ONLINELOG/group_3.263.873380343'' TO ''/u04/app/oracle/redo/redo03.log''";
    SQL "ALTER DATABASE RENAME FILE ''+FRA/ASMDEMO1/ONLINELOG/group_3.260.873380343'' TO ''/u04/app/oracle/redo/redo01.log''";
    SQL "ALTER DATABASE RENAME FILE ''+DATA/ASMDEMO1/ONLINELOG/group_2.262.873380341'' TO ''/u04/app/oracle/redo/redo02.log''";
    SQL "ALTER DATABASE RENAME FILE ''+FRA/ASMDEMO1/ONLINELOG/group_2.259.873380341'' TO ''/u04/app/oracle/redo/redo04.log''";
    SQL "ALTER DATABASE RENAME FILE ''+DATA/ASMDEMO1/ONLINELOG/group_1.261.873380341'' TO ''/u04/app/oracle/redo/redo05.log''";
    SQL "ALTER DATABASE RENAME FILE ''+FRA/ASMDEMO1/ONLINELOG/group_1.258.873380341'' TO ''/u04/app/oracle/redo/redo06.log''";
    }
  6. Find the system change number (SCN) to make the database consistent:

    RMAN> RESTORE DATABASE PREVIEW DEVICE TYPE SBT;

    The output includes the name and location of backup pieces that will be used when restoring the database.

  7. Recall any required backup pieces that were archived.

    If the RESTORE...PREVIEW command output contains a section named List of remote backup files, it means that some required backup pieces were archived. Recall these backup pieces using the following command:

    RMAN> RESTORE DATABASE PREVIEW RECALL DEVICE TYPE SBT;
  8. Restore the database using the following command:
    RESTORE DATABASE DEVICE TYPE SBT;
  9. Recover the database to that point:

    RMAN> RECOVER DATABASE DEVICE TYPE SBT UNTIL SCN scn;

    where scn is the SCN identified in the previous step.

    For Oracle Database 12c Release 2 (12.2) and higher, you can use the RECOVER DATABASE UNTIL AVAILABLE REDO command.

  10. Open the database with the RESETLOGS option after restore and recovery is complete:

    RMAN> ALTER DATABASE OPEN RESETLOGS;