Before You Begin
This 15-minute tutorial shows you how to recover an on-premises container database (CDB) by using Recovery Manager (RMAN) backups that are stored in Oracle Database Backup Cloud Service on Oracle Cloud Infrastructure Classic.
Background
RMAN commands can be used to back up on-premises Oracle databases to Oracle Database Backup Cloud Service. The Oracle Database Cloud Backup Module, a System Backup to Tape (SBT) interface, integrates RMAN with Oracle Database Backup Cloud Service. Database restore and recovery is performed using RMAN commands. The time taken to complete the recovery depends on the CDB size and network resources.
What Do You Need?
- Subscription to Oracle Database Backup Cloud Service
- Oracle Database Cloud Backup Module installation and configuration on the target host
- Oracle Database 18c installation with the following:
ARCHIVELOG
mode configured- Control file and server parameter file (spfile) autobackups configured
- Backups of the control file, all data files, and archived redo log files until the point in time to which the CDB must be recovered
- Password required to decrypt RMAN backups stored using
Oracle Database Backup Cloud Service
All backups to Oracle Database Backup Cloud Service must be encrypted. For this OBE, password-based encryption was used when creating the CDB backups. - Time to which the CDB must be recovered
- DBID of the target CDB
Point-in-time recovery (PITR) was performed on this CDB at
06:08:38 on 26-Jan-2018 to correct an earlier error. The OPEN
RESETLOGS
operation performed after this PITR created a
new CDB incarnation.
Prepare
to Perform Incomplete Recovery of the CDB
- Set the
ORACLE_SID
,ORACLE_HOME
, andNLS_DATE_FORMAT
parameters for the current session.
# setenv ORACLE_SID ora18
# setenv ORACLE_HOME /u01/app/oracle/product/18.1.0/dbhome_1
# setenv NLS_DATE_FORMAT "dd-mon-yyyy hh24:mi:ss" - Start an RMAN session.
# rman
- Connect to the root of the target CDB
as the
SYS
user. You can also connect to the root as a common user with theSYSBACKUP
privilege. Note that a recovery catalog is not used.
# connect TARGET "sys@ora18 as SYSDBA"
Enter the password for theSYS
user when prompted. - Display the current RMAN
configuration.
Observe that the default channel for the device type SBT is configured for Oracle Database Backup Cloud Service on Oracle Cloud Infrastructure Classic. The SBT_LIBRARY parameter shows the location of the SBT library that integrates RMAN with Oracle Database Backup Cloud Service. The OPC_FILE parameter shows the location of the Oracle Database Cloud Backup Module configuration file. These parameters are set during the installation of the Oracle Database Cloud Backup Module.RMAN> show all;
RMAN configuration parameters for database with db_unique_name ORA18 are: . . . CONFIGURE CONTROL FILE AUTOBACKUP ON; # default CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '%F'; # default CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE SBT_TAPE TO '%F'; # default . . . CONFIGURE CHANNEL DEVICE TYPE 'SBT_TAPE' PARMS 'SBT_LIBRARY=/u01/app/oracle/product/18.0.0/dbhome_1/lib/libopc.so, SBT_PARMS=(OPC_PFILE=/u01/app/oracle/product/18.0.0/dbhome_1/dbs/opcora18.ora)'; . . .
Note: The ellipses in the output represent lines that have been omitted for brevity. - List the CDB incarnations.
RMAN> SELECT incarnation#, status, resetlogs_change# "
RESETLOGS CHANGE
SCN", to_date(resetlogs_time,'dd-mon-yyyy hh24:mi:ss') "RESETLOGS CHANGE
TIME"
2> FROM v$database_incarnation;
INCARNATION# STATUS RESETLOGS CHANGE SCNRESETLOGS CHANGE
TIME ------------ ------- -------------------- --------------------- 1 PARENT 1 05-JAN-18 00:01:04 2 PARENT 1431941 26-JAN-18 06:08:38 3 CURRENT 1480412 28-JAN-18 23:38:56 - Determine the target recovery time for the CDB. The CDB must be recovered to the state that it was in at the target recovery time.
In this example, the target recovery time being used is 23:25:00 on 27-jan-2018. - Determine the CDB incarnation that corresponds to the target recovery time.
The target time for CDB recovery may be in a noncurrent database incarnation. In such cases, you must determine the database incarnation at the target time.
RMAN> SELECT dbinc.incarnation# FROM 2> (SELECT incarnation#, resetlogs_time reset_time, PRIOR resetlogs_time next_reset_time 3> FROM v$database_incarnation START WITH status = 'CURRENT' 4> CONNECT BY PRIOR prior_incarnation# = incarnation#)dbinc 5> WHERE dbinc.reset_time <= to_date('27-jan-2018 18:25:00','dd-mon-yyyy hh24:mi:ss') 6> AND dbinc.next_reset_time > to_date('27-jan-2018 18:25:00','dd-mon-yyyy hh24:mi:ss'); INCARNATION# ------------ 2
Recover the CDB to the Required Time
- Place the CDB in
NOMOUNT
mode.RMAN> shutdown immediate;
RMAN> startup nomount; - Set the password required to decrypt the RMAN backups being restored from Oracle Database Backup Cloud Service.
Backups to Oracle Database Backup Cloud Service are always encrypted. Before restoring these backups, you must provide the decryption password. This must the same password that was used while encrypting the backups. In the following command, replace encryption_password with the password that was used to encrypt your backups.RMAN> set decryption identified by 'encryption_password';
- Restore the spfile from the CDB autobackup.
Your output should look similar to restore_spfile.txt.RMAN> run 2> { 3> set dbid 1259015779; 4> allocate channel c1 type sbt PARMS='SBT_LIBRARY=/u01/app/oracle/product/18.0.0/dbhome_1/lib/libopc.so, SBT_PARMS=(OPC_PFILE=/u01/app/oracle/product/18.0.0/dbhome_1/dbs/opcora18.ora)'; 5> restore spfile from autobackup; 6> }
- Restart the instance using the restored spfile.
RMAN> startup force nomount;
- Restore the control file from the CDB autobackup.
Your output should look similar to restore_controlfile.txt.RMAN> run 2> { 3> set dbid 1259015779; 4> allocate channel c1 type sbt PARMS='SBT_LIBRARY=/u01/app/oracle/product/18.0.0/dbhome_1/lib/libopc.so, SBT_PARMS=(OPC_PFILE=/u01/app/oracle/product/18.0.0/dbhome_1/dbs/opcora18.ora)'; 5> set until time "to_date('27-jan-2018 18:25:00','dd-mon-yyyy hh24:mi:ss')"; 6> restore controlfile from autobackup; 7> }
- Place the CDB in MOUNT mode.
RMAN> alter database mount;
- Reset the CDB to the incarnation that corresponds to the target recovery time.
Based on the output of Step 7 in Section 1, Prepare to Perform Incomplete Recovery of the CDB, the database incarnation that corresponds to the target recovery time is incarnation 2.
Your output should look similar to reset_incarnation.txt.RMAN> reset database to incarnation 2;
- Restore and recover the CDB to the required point in time.
Allocating multiple channels speeds up the restore operation. Use the followingRUN
block to allocate channels, restore the CDB, and then recover the CDB.
Your output should look similar to restore_db.txt.RMAN> run 2> { 3> allocate channel c1 type sbt PARMS='SBT_LIBRARY=/u01/app/oracle/product/18.0.0/dbhome_1/lib/libopc.so, SBT_PARMS=(OPC_PFILE=/u01/app/oracle/product/18.0.0/dbhome_1/dbs/opcora18.ora)'; 4> allocate channel c2 type sbt PARMS='SBT_LIBRARY=/u01/app/oracle/product/18.0.0/dbhome_1/lib/libopc.so, SBT_PARMS=(OPC_PFILE=/u01/app/oracle/product/18.0.0/dbhome_1/dbs/opcora18.ora)'; 5> set until time "to_date('27-jan-2018 18:25:30','dd-mon-yyyy hh24:mi:ss')"; 6> restore database; 7> recover database; 8> }
- Open the CDB with
RESETLOGS
.
Because incomplete recovery was performed, the CDB must be opened withRESETLOGS
. Database changes after the target recovery time are abandoned.RMAN> alter database open resetlogs;
- List the CDB incarnations.
Observe from the output that a new incarnation, 4, was created after the CDB PITR operation completed and the CDB was opened with RESETLOGS.RMAN> list incarnation; List of Database Incarnations DB Key Inc Key DB Name DB ID STATUS Reset SCN Reset Time ------- ------- -------- ---------------- --- ---------- ---------- 1 1 ORA18 1259015779 PARENT 1 05-JAN-18 2 2 ORA18 1259015779 PARENT 1431941 26-JAN-18 3 3 ORA18 1259015779 ORPHAN 1480412 28-JAN-18 4 4 ORA18 1259015779 CURRENT 1480412 30-JAN-18
Want
to Learn More?
- Oracle Database Backup Cloud Service Documentation
- Oracle Database Backup and Recovery User's Guide, Release 18c