Duplicating CDBs and PDBs
(source Oracle Docs)
Use the DUPLICATE command to duplicate CDBs, one or more PDBs, sparse CDBs, and sparse PDBs. The steps to duplicate CDBs and PDBs are similar to those of duplicating non-CDBs with minor variations to the procedure for duplicating a non-CDB. This section describes how to duplicate CDBs and PDBs.
1. Duplicating CDBs
Use the DUPLICATE command to duplicate CDBs.
Duplicating a whole CDB or one or more PDBs requires only minimal adjustments to the procedure for duplicating a non-CDB, as described in “Duplicating the Whole Database”.
To duplicate a CDB:
While planning to Duplicate a Database:
Use the PLUGGABLE DATABASE syntax of the BACKUP command to copy only the backups of a specific PDB.
The following command transfers the backup files for the entire CDB:
BACKUP COPY OF DATABASE;
The following command transfers only the backup files for the PDB pdb3:
BACKUP COPY OF PLUGGABLE DATABASE pdb3;
Ensure that the prerequisites for the selected duplication technique are met.
Prepare the auxiliary instance, as described in “Preparing the Auxiliary Instance”, with the following changes:
We must create the auxiliary instance as a CDB. To do so, start the instance with the following declaration in the initialization parameter file:
enable_pluggable_database=TRUE
When instructed to create an initialization parameter file for the auxiliary instance, we must copy the file from the source database. This ensures that the auxiliary instance is also a CDB. After we copy the file, perform the following steps:
Modify the DB_NAME parameter
Modify the various destination or location parameters
When instructed to connect to the necessary instances, connect to the root as a user with SYSDBA or SYSBACKUP privilege. On both instances, the password for the user performing the duplication must be the same.
Start RMAN and connect to the root as a user with the SYSDBA or SYSBACKUP privilege.
On both the auxiliary instance and the target database, the password for the user performing the duplication must be the same.
Place source database in a proper state, if necessary, as described in “Placing the Source Database in a Proper State”.
Configure RMAN channels, if necessary, as described in “Configuring RMAN Channels for Use in Duplication”.
The primary task of duplication is performed by RMAN channels. Configuring additional channels improves the duplication performance.
Use the DUPLICATE command to duplicate the source CDB.
2. Duplicating Sparse CDBs
Use the DUPLICATE command to duplicate sparse CDBs.
To duplicate a sparse CDB:
Complete the planning tasks:
Use the PLUGGABLE DATABASE syntax of the BACKUP command to copy only the backups of a specific PDB.
The following command transfers the backup files for the entire CDB:
BACKUP COPY OF DATABASE;
The following command transfers only the backup files for the PDB pdb3:
BACKUP COPY OF PLUGGABLE DATABASE pdb3;
Ensure that the prerequisites for the selected duplication technique are met.
Prepare the auxiliary instance:
we must create the auxiliary instance as a CDB. To do so, start the instance with the following declaration in the initialization parameter file:
enable_pluggable_database=TRUE
When instructed to create an initialization parameter file for the auxiliary instance, we must copy the file from the source database.
This ensures that the auxiliary instance is also a CDB.
After we copy the file, perform the following steps:
Modify the DB_NAME parameter
Modify the various destination/location parameters
When instructed to connect to the necessary instances, connect to the root as a user with SYSDBA or SYSBACKUP privilege.
On both instances, the password for the user performing the duplication must be the same.
Start RMAN and connect to the root as a user with the SYSDBA or SYSBACKUP privilege.
On both the auxiliary instance and the target database, the password for the user performing the duplication must be the same.
Place the source database in a proper state.
The primary task of duplication is performed by RMAN channels. Configuring additional channels improves the duplication performance.
Run the DUPLICATE command with the FROM SPARSE option.
For example, the following command duplicates the CDB on to cdb2:
DUPICATE FROM SPARSE TO cdb2 DATABASE;
3. Duplicating PDBs
we can duplicate a PDB to a new multitenant container database (CDB) or an existing CDB.
a. Duplicating PDBs –
1. we can duplicate a single PDB, a set of PDBs, or a set of tablespaces within a PDB by using the DUPLICATE command.
2. To duplicate PDBs, we must log in to the root of the CDB as a user with the SYSDBA or SYSBACKUP privilege.
3. When duplicating a PDB to a new CDB, we must create the auxiliary instance as a CDB.
4. To do so, start the auxiliary instance with the declaration enable_pluggable_database=TRUE in the initialization parameter file.
5. When we duplicate one or more PDBs, RMAN also duplicates the root (CDB$ROOT) and the CDB seed (PDB$SEED).
6. The resulting duplicate database is a fully functional CDB that contains the root, the CDB seed, and the duplicated PDBs.
4. Techniques for Duplicating PDBs
Technique Description Additional Information
Duplicate a PDB to an existing CDB To duplicate a PDB into
an existing CDB, use the
DUPLICATE PLUGGABLE DATABASE
pdb_name TO cdb_name syntax.
Here, cdb_name is the name
of an existing CDB. Duplicating a PDB to an Existing CDB
Duplicate specified PDBs
to a new CDB Use one of the following
techniques:
a. Duplicate the specified PDBs
to a new CDB by using the
following syntax:
DUPLICATE DATABASE TO cdb_name
PLUGGABLE DATABASE pdb_name;
b. Use a comma-delimited list to
duplicate multiple PDBs.
Duplicate all the PDBs,
except the PDBs specified by pdb_name,
to a new CDB by using the
following syntax:
DUPLICATE DATABASE TO cdb_name
SKIP PLUGGABLE DATABASE pdb_name
Use a comma-delimited list to
specify multiple PDBs that
must be excluded. Duplicating a PDB to a New CDB
Duplicate specified tablespaces
within a PDB to a new CDB Use one of the following techniques:
a. Duplicate specified tablespaces
within a PDB to a new CDB
by using the following syntax:
DUPLICATE DATABASE TO cdb_name
TABLESPACE pdb_name:tablespace_name;
The tablespace name must be prefixed
with the name of the PDB that contains
the tablespace.
If we omit the name of the PDB,
root is taken as the default.
b. Duplicate all tablespaces in the
CDB except the specified tablespaces
to a new CDB by using the following
syntax:
c. DUPLICATE DATABASE TO cdb_name
SKIP TABLESPACE pdb_name:tablespace_name
Duplicating Tablespaces Within a PDB to a New CDB
5. Limitation and Restrictions on Duplicating a PDB to an Existing CDB
Duplicating a PDB to an existing CDB is subject to certain restrictions.
1. Only active database duplication is supported.
2. Only the following clauses of the DUPLICATE command are supported:
a. NORESUME,
b. DB_FILE_NAME_CONVERT,
c. SECTION SIZE, and
d. USING COMPRESSED BACKUPSET.
3. The following clauses of the DUPLICATE command are not supported:
a. SPFILE,
b. NO STANDBY,
c. FARSYNC STANDBY, and
d. LOG_FILE_NAME_CONVERT.
4. Duplicating a PDB to a CDB that is a standby database is not supported.
5. Only one PDB can be duplicated at a time.
6. Partial PDB duplication is not supported, only complete PDB duplication is supported.
For example, we cannot include or exclude specific tablespaces while duplicating a PDB.
7. Duplicating a non-CDB as a PDB in an existing CDB is not supported.
8. Duplicating PDBs that contain TDE-encrypted tablespaces is not supported.
6. Duplicating a PDB to an Existing CDB
Use the DUPLICATE command to duplicate a PDB to an existing CDB.
To duplicate a PDB to an existing CDB:
a. Ensure that the required prerequisites are met. This includes the following:
i. Prerequisites for active database duplication
ii. Additional prerequisites for duplicating a PDB to an existing CDB
a. limitations of duplicating a PDB to an existing CDB
b. Choose a strategy for naming duplicate database files
c. Create the directories that store the duplicate database files on the destination CDB
d. Establish Oracle net connectivity between the source CDB and the destination CDB
e. Start RMAN and make the following connections:
Connect AS TARGET to the root of the source CDB as a common user with the SYSDBA or SYSBACKUP privilege.
Connect AS AUXILIARY to the root of the destination CDB as a common user with the SYSDBA or SYSBACKUP privilege.
Note:
To duplicate multiple PDBs,
a. use a separate RMAN session for each PDB duplication.
b. Ensure that the destination CDB is open in read-write mode.
c. Configure RMAN channels.
d. The primary task of duplication is performed by RMAN channels.
e. Configuring additional channels improves the duplication performance.
7. Duplicate the PDB by using the DUPLICATE PLUGGABLE DATABASE command.
The following command duplicates the PDB mypdb to an existing CDB cdb_sales.
DUPLICATE PLUGGABLE DATABASE mypdb TO cdb_sales
# DUPLICATE PLUGGABLE DATABASE mypdb AS pdb_dup TO cdb_sales – duplicate pdb to a different name
DB_FILE_NAME_CONVERT(‘cdb1′,’pdb1’)
FROM ACTIVE DATABASE
SECTION SIZE 400M;
Delete the foreign archived redo log files that were restored to the location specified by the
remote_recovery_file_dest initialization parameter as part of the duplication.
Note:
Duplicating a PDB to an existing CDB is supported starting with Oracle Database Release 18c.
Example: Duplicating a PDB to an Existing CDB by Using Active Duplication
8. Duplicating a PDB to a New CDB
Use the DUPLICATE command to duplicate one or more PDBs to a new CDB.
To duplicate a PDB to a new CDB:
a. Complete Planning Tasks to Duplicate a Database
b. Making Backups Accessible to the Duplicate Instance
c. Making Disk Backups Accessible Without Shared Disk
Use the PLUGGABLE DATABASE syntax of the BACKUP command to copy only the backups of a specific PDB.
Example
The following command transfers only the backups files for the PDB pdb3:
BACKUP COPY OF PLUGGABLE DATABASE pdb3;
a. Ensure that the prerequisites for the selected duplication technique are met
b. Prepare the auxiliary instance with the following changes:
i. we must create the auxiliary instance as a CDB.
ii. To do so, start the instance with the following declaration in the initialization parameter file:
enable_pluggable_database=TRUE
iii. When instructed to create an initialization parameter file for the auxiliary instance, we must copy the file from the source database.
iv. This ensures that the auxiliary instance is also a CDB.
v. After we copy the file, perform the following steps:
a. Modify the DB_NAME parameter
b. Modify the various destination/location parameters
vi. When instructed to connect to the necessary instances, connect to the root as a user with SYSDBA or SYSBACKUP privilege.
vii. On both instances, the password for the user performing the duplication must be the same.
c. Start RMAN and connect to the root as a user with the SYSDBA or SYSBACKUP privilege.
d. On both the auxiliary instance and the target database, the password for the user performing the duplication must be the same.
e. Place source database in proper state.
f. Configure RMAN channels.The primary task of duplication is performed by the RMAN channels.
g. Configuring additional channels improves the duplication performance.
9. Duplicate the PDB by using the DUPLICATE … PLUGGABLE DATABASE command.
Examples: Duplicating PDBs
a. To duplicate the PDB pdb1 to the CDB cdb1, use the following command:
DUPLICATE DATABASE TO cdb1 PLUGGABLE DATABASE pdb1;
b. To duplicate the PDBs pdb1, pdb3, and pdb4 to the database cdb1, use the following command:
DUPLICATE DATABASE TO cdb1 PLUGGABLE DATABASE pdb1,pdb3,pdb4;
c. To duplicate all the PDBs in the CDB, except the PDB pdb3, use the following command:
DUPLICATE DATABASE TO cdb1 SKIP PLUGGABLE DATABASE pdb3;