Oracle Cloud Infrastructure Documentation

Recovering a Database from a CLI Backup

Note

This topic is not applicable to Exadata DB Systems.

This topic explains how to perform a complete or point-in-time recovery of an existing database from a backup created with the dbcli create-backup command. The backup resides in the local Fast Recovery Area on the DB System.

To initiate the recovery, you'll use the Oracle Database CLI Reference command and specify the recovery type parameter (either --recoverytype or just -t). You can specify the following types of recovery:

  • -t Latest for a complete recovery
  • -t SCN -s <scn> for a recovery using a system change number (SCN) as the end point of the recovery
  • -t PITR <mm/dd/yyyy hh:mm:ss> for a database point-in-time (incomplete) recovery based on a time stamp

The dbcli create-recovery attempts to perform a full recovery of the database. For information on performing a partial recovery (datafile, tablespace and PDB), see the Oracle Database Backup Recovery Guide for version 18.1, 12.2, 12.1, or 11.2.

Prerequisites

  • The backup must have been created with the dbcli create-backup command.
  • If the database is configured with Transparent Data Encryption (TDE), make sure the password-based and autologin TDE wallets are present in the following location:

    /opt/oracle/dcs/commonstore/wallets/tde/<db_unique_name>

Recovering the Database

  1. SSH to the DB System.

    ssh -i <private_key_path> opc@<db_system_ip_address> 
  2. Log in as opc and then sudo to the root user. Use sudo su - with a hyphen to invoke the root user's profile, which will set the PATH to the dbcli directory (/opt/oracle/dcs/bin).

    login as: opc
    			
    [opc@dbsys ~]$ sudo su - 
  3. Find the ID of database you want to recover by using the dbcli list-databases command. You'll need the ID for the following step.

    [root@dbsys ~]# dbcli list-databases
    ID                                       DB Name    DB Version CDB        Class    Shape    Storage    Status   
    ---------------------------------------- ---------- ---------- ---------- -------- -------- ---------- ----------
    5a3e980b-e0fe-4909-9628-fcefe43b3326     prod       12.1.0.2   true       OLTP     odb1     ACFS       Configured 
  4. Initiate the recovery by using the Oracle Database CLI Reference command and specifying the database ID, recovery type parameter (-t), and any parameter required for the recover type, like the time stamp or system change number.

    The following example initiates a complete recovery.

    [root@dbsys ~]# dbcli create-recovery --dbid 5a3e980b-e0fe-4909-9628-fcefe43b3326 --recoverytype Latest
    {
      "jobId" : "c9f81228-2ce9-43b4-88f6-b260d398cf06",
      "status" : "Created",
      "message" : null,
      "reports" : [ ],
      "createTimestamp" : "August 08, 2016 18:20:47 PM UTC",
      "description" : "Create recovery for database id :5a3e980b-e0fe-4909-9628-fcefe43b3326",
      "updatedTime" : "August 08, 2016 18:20:47 PM UTC"
    }

    The following example initiates a point-in-time recovery of the specified database:

    [root@dbsys ~]# dbcli create-recovery --dbid d4733796-dbea-4155-8606-24a85d64bd74 --recoverytype PITR --recoveryTimeStamp 08/09/2016 5:12:15

    Note the job ID in the command output.

  5. Check the status of the recovery by using the dbcli describe-job command with the job ID from the previous step.

    [root@dbsys ~]# dbcli describe-job -i c9f81228-2ce9-43b4-88f6-b260d398cf06
     
    Job details                                                     
    ----------------------------------------------------------------
                         ID:  c9f81228-2ce9-43b4-88f6-b260d398cf06
                Description:  Create recovery for database id :5a3e980b-e0fe-4909-9628-fcefe43b3326
                     Status:  Success
                    Created:  August 8, 2016 6:20:47 PM UTC
                    Message: 
     
    Task Name                                Start Time                          End Time                            Status   
    ---------------------------------------- ----------------------------------- ----------------------------------- ----------
    Database recovery validation             August 8, 2016 6:20:47 PM UTC       August 8, 2016 6:21:07 PM UTC       Success  
    Database recovery                        August 8, 2016 6:21:07 PM UTC       August 8, 2016 6:22:34 PM UTC       Success  
    enable block change tracking             August 8, 2016 6:22:34 PM UTC       August 8, 2016 6:22:35 PM UTC       Success  
    Open database                            August 8, 2016 6:22:35 PM UTC       August 8, 2016 6:22:44 PM UTC       Success  
    Restart database                         August 8, 2016 6:22:44 PM UTC       August 8, 2016 6:23:41 PM UTC       Success  
    Persist Recovery Metadata                August 8, 2016 6:23:41 PM UTC       August 8, 2016 6:23:41 PM UTC       Success

You can also check the database restore report logs on the DB System at:

/opt/oracle/dcs/log/<nodename>/rman/bkup/<db_unique_name>