Example: Restoring and Recovering PDBs
The multitenant architecture enables an Oracle database to function as a multitenant container database (CDB) that includes zero, one, or many customer-created pluggable databases (PDBs). All Oracle databases before Oracle Database 12c are non-CDBs.
A CDB includes the following components: root, seed, and user-created PDBs. The root stores the common users and Oracle-supplied metadata such as the source code for Oracle-supplied packages. The seed is a template that can be used to create new PDBs. A PDB is a portable collection of schemas, schema objects, and nonschema objects that appears to an Oracle Net client as a non-CDB.
This section demonstrates various restore and recovery scenarios for PDBs. The steps to restore and recover a PDB are similar to those used for restore and recover operations on non-CDBs. This section contains the following examples:
Performing Complete Recovery of the Whole PDB
This example demonstrates how to perform complete recovery for a PDB in the protected database.
To restore and recover a whole PDB:
-
Ensure that the prerequisites described in “Prerequisites for Restoring and Recovering Data from Recovery Appliance” are met.
-
Use RMAN to connect to the root of the CDB as
TARGETand the Recovery Appliance catalog asCATALOG.See Also: “Connecting to the Protected Database and Recovery Appliance Using CLI”
-
Identify the PDB that needs to be restored by running the following query in the CDB:
SELECT name FROM v$pdbs; -
Restore and recover the required PDB in your protected database.
The following command restores and recovers the PDB
hr_pdb:RUN { ALTER PLUGGABLE DATABASE "hr_pdb" CLOSE IMMEDIATE; RESTORE PLUGGABLE DATABASE 'hr_pdb'; RECOVER PLUGGABLE DATABASE 'hr_pdb'; ALTER PLUGGABLE DATABASE "hr_pdb" OPEN; }
Performing Point-in-Time Recovery for the Whole PDB
This example demonstrates how to perform point-in-time recovery for one or more PDBs in your protected database. Specify the SET UNTIL clause to indicate the point to which the PDB must be recovered.
To restore and recover a PDB to a specific point-in-time:
-
Ensure that the prerequisites described in “Prerequisites for Restoring and Recovering Data from Recovery Appliance” are met.
-
Use RMAN to connect to the root of the CDB as
TARGETand the Recovery Appliance catalog asCATALOGas described in “Connecting to the Protected Database and Recovery Appliance Using CLI”. -
Identify the PDB that needs to be restored by running the following query in the CDB:
SELECT name FROM v$pdbs; -
Restore and recover the affected PDB to the specified point in time.
The following command restores and recovers the PDB
hr_pdbto the point in time specified by theSET UNTILclause.RUN { SET UNTIL TIME "to_date('2014-08-16 09:00:00','YYYY-MM-DD HH24:MI:SS')"; ALTER PLUGGABLE DATABASE "hr_pdb" CLOSE IMMEDIATE; RESTORE PLUGGABE DATABASE 'hr_pdb'; RECOVER PLUGGABLE DATABASE 'hr_pdb'; ALTER PLUGGABLE DATABASE hr_pdb OPEN RESETLOGS; }
Recovering Specific Data Files in a PDB
Restoring and recovering data files in a PDB is similar to restoring and recovering any data file using RMAN. This example demonstrates how to restore and recover a data file in a PDB.
To restore and recover a specific data file in a PDB:
-
Ensure that the prerequisites described in “Prerequisites for Restoring and Recovering Data from Recovery Appliance” are met.
-
Use RMAN to connect to the root of the CDB as
TARGETand the Recovery Appliance catalog asCATALOGas described in “Connecting to the Protected Database and Recovery Appliance Using CLI”. -
Identify the PDB that needs to be restored by running the following query in the CDB:
SELECT name FROM v$pdbs; -
Identify the number of the data file in the PDB that needs to be recovered using the following query:
SELECT p.PDB_ID, p.PDB_NAME, d.FILE_ID, d.TABLESPACE_NAME, d.FILE_NAME FROM DBA_PDBS p, CDB_DATA_FILES d WHERE p.PDB_ID = d.CON_ID ORDER BY p.PDB_ID; -
Restore and recover the affected data files in the PDB.
The following example restores and recovers data file number 10 in the PDB.
RUN
{
SQL 'ALTER DATABASE DATAFILE 10 OFFLINE';
RESTORE DATAFILE 10;
RECOVER DATAFILE 10;
SQL 'ALTER DATABASE DATAFILE 10 ONLINE';
}
Recovering Specific Tablespaces in a PDB
This example demonstrates how to restore and recover the tablespace USR_TBS contained in the PDB SH_PDB in your protected database.
Restoring and recovering a tablespace in a PDB is similar to a normal tablespace restore and recovery. The difference is that you need to map the tablespace to the pluggable database (pdb_name:tablespace_name).
To restore and recover specific tablespaces in a PDB:
-
Ensure that the prerequisites described in “Prerequisites for Restoring and Recovering Data from Recovery Appliance” are met.
-
Use RMAN to connect to the root of the CDB as
TARGETand the Recovery Appliance catalog asCATALOGas described in “Connecting to the Protected Database and Recovery Appliance Using CLI”. -
Place the affected tablespace in offline mode.
The following example places the tablespace
use_tbsin the PDBsh_pdbin offline mode.ALTER TABLESPACE sh_pdb:usr_tbs OFFLINE; -
Restore and recover the affected tablespaces contained in the PDB within your protected database.
The following example restore and recovers the tablespace
usr_tbsin the PDBsh_pdb.RUN { RESTORE TABLESPACE sh_pdb:usr_tbs; RECOVER TABLESPACE sh_pdb:usr_tbs; } -
Make the restored and recovered tablespace online.
The following example brings the tablespace
usr_tbsin the PDBsh_pdbonline.ALTER TABLESPACE sh_pdb:usr_tbs ONLINE;