Container Database CDB and Pluggable database PDB Backup and Recovery.

Introduction: –

 
As we know that Oracle introduced multitenant Container Database CDB and Pluggable database PDB Backup and Recovery in 12c. Using RMAN client we can perform the backup of entire Container Database (CDB) or individual Pluggable Database (PDB) and also perform the point-in- time recovery.
 
 
Before starting the RMAN backup, we should be aware about SQL interface for RMAN that another greatest and easiest feature that we can use SQL statement through RMAN. Prior to 12c, very limited SQL statement was supported with RMAN.
 
Container Database CDB and Pluggable database PDB Backup and Recovery
 
 

In this article we will explain how to use RMAN backup and recovery in multi-tenant environment.


CDB, PCDB and ROOT Backup:-

 
We can back up the Container Database (CDB) as same as non-container database using below RMAN command.          
 
RMAN> BACKUP DATABASE PLUS ARCHIVELOG;
 
Backup Pluggable database (PDB) using below RMAN command.
 
RMAN> BACKUP PLUGGABLE DATABASE PDBORCL1, PDBORCL2;
 
Or connect to Pluggable database (PDB).
 
 
$RMAN target sys@PDBORCL1
 
RMAN> BACKUP DATABASE;
 
We can backup root using below.
 
RMAN> BACKUP DATABASE ROOT;
 
 

CDB,PCDB and ROOT Restore & Recovery:-

 
Restoration of container database (CDB) and non-container database both are same. We can restore the CDB using below scripts.
 
RMAN> RUN {
STARTUP MOUNT;
RESTORE DATABASE;
RECOVER DATABASE;
ALTER DATABASE OPEN;
}
 
Above script will restore whole container (CDB) and pluggable database (PDB).
 
For restoration of ROOT use below script.
 
 
RMAN> RUN {
STARTUP MOUNT;
RESTORE DATABASE ROOT;
RECOVER DATABASE ROOT;
ALTER DATABASE OPEN;
}
 
 
There are two ways to restore Pluggable Database (PDB), either restore from root container or directly connect to Pluggable Database (PDB).
 
 
RMAN> RUN {
RESTORE PLUGGABLE DATABASE PDBORCL1, PDBORCL2;
RECOVER PLUGGABLE DATABASE PDBORCL1, PDBORCL2;
ALTER PLUGGABLE DATABASE PDBORCL1, PDBORCL2 OPEN;
}
 
 
Connect Pluggable database (PDB) and do the Restoration and recovery using below script.
 
 
$ RMAN TARGET=sys@PDBORCL
RMAN> RUN {
RESTORE DATABASE;
RECOVER DATABASE;
}
 
 
 

Point-in-time recovery of CDB and PDB:-

 
 
Follow the below steps to recover the database until a specified SCN, time or log sequence
 

Step 1: Shutdown and startup mount the database.

 
SQL> SHUTDOWN IMMEDAITE;
SQL> STARTUP MOUNT;
 

Step 2: First of all, determine the SCN, time or log sequence that you want to recovery.

 
SCN – you can get the SCN from alert.log file
Sequence – v$log_history
 
 

Step 3. Perform the incomplete recovery

 
If specifying a time, then set NLS_LANG and NLS_DATE_FORMAT environment variables.
 
RUN {
SET UNTIL TIME ‘SEP 10 2019 12:00:00’;
# SET UNTIL SCN 400; # alternatively, specify SCN
# SET UNTIL SEQUENCE 423; # alternatively, specify log seq
RESTORE DATABASE; 
RECOVER DATABASE;
}

Note:- If datafile destination different as compare to source database. Use SET NEWNAME FOR DATAFILE  and then use SWITCH DATAFILE ALL. Pls check here for more information.
Before execute resetlogs , need to update redologfile and tempfiles. For more info check here.

 

Step 4. Open database with resetlogs.

 
 
SQL> ALTER DATABASE OPEN RESETLOGS;
 

Leave a Comment