Steps to duplicate PDB database from one CDB to another CDB

Step 1: Check source CDB database is in Archive Mode

Archive log list

Step 2: Configure tnsnames.ora for the source site and the dest site.

Make entry on both database for connectivity in tnsnames.ora file

source = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = Prod001.orcl.com)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME =  ORCL01) ) )

dest = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = test002.orcl.com)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = ORC02) ) )

Step 3: On Source and destination site, Check the connectivity:

$lsnrctl start

$tnsping source
$tnsping dest

$sqlplus sys/<password>@source as sysdba
$sqlplus sys/<password>@dest as sysdba

Example: Test connectivity from both end source and destination server

Source: PEGA container database
Target: IC container database

$tnsping pega
$tnsping ic 

$sqlplus sys/<password>@pega as sysdba
$sqlplus sys/<password>@ic as sysdba

Step 4: Ensure that the source and dest have the same sys password.

SQL>Alter user sys identified by <password>;

Step 5. On the dest side, create directory used for duplicating.

--Create directory for storing archive logs when duplicating:
$mkdir F:\recovery

-- Set remote_recovery_file_dest parameter using the above directory:
SQL> alter system set remote_recovery_file_dest='F:\recovery';

-- Create directory used for storing datafiles of the new PDB: (in my case OMF is --- used so i only give present directory name for destination)
$mkdir -p C:\oradata\IC\dev

Step 6. Run Duplicate command to duplicate the database from source to dest

On source site, open the PDB we want to duplicate:

alter pluggable database pdb01 open read write;

On dest site, duplicate PDB via RMAN:

$rman
RMAN> connect target sys/<password>@source

RMAN> connect auxiliary sys/<password>@dest

RMAN> DUPLICATE PLUGGABLE DATABASE pdb01 as dev TO orc181u02 DB_FILE_NAME_CONVERT('pdb01','dev') FROM ACTIVE DATABASE SECTION SIZE 400M;

Note: you can use ASM disk group name for DB_FILE_NAME_CONVERT, for example : DB_FILE_NAME_CONVERT=('+DATA','/refresh/64bit/app/oracle/oradata/ORC181U/dev') .

Example:

c:\Users\e3019447>rman target sys@pega auxiliary sys@ic

Recovery Manager: Release 19.0.0.0.0 - Production on Wed Jan 22 09:22:59 2025
Version 19.25.0.0.0

Copyright (c) 1982, 2024, Oracle and/or its affiliates.  All rights reserved.

target database Password:
connected to target database: PEGA (DBID=2944853039)
auxiliary database Password:
PL/SQL package SYS.DBMS_BACKUP_RESTORE version 19.23.00.00 in AUXILIARY database is not current
PL/SQL package SYS.DBMS_RCVMAN version 19.23.00.00 in AUXILIARY database is not current
connected to auxiliary database: IC (DBID=3161858375)


RMAN> DUPLICATE PLUGGABLE DATABASE PDB1 as DEV TO IC DB_FILE_NAME_CONVERT('F:\TEST\ORACLE19\ORADATA\PEGA','F:\ora19base\oradata\IC') FROM ACTIVE DATABASE SECTION SIZE 400M;

Starting Duplicate PDB at 22-JAN-25
using channel ORA_AUX_DISK_1
current log archived
duplicating Online logs to Oracle Managed File (OMF) location
current log archived

contents of Memory Script:
{
   set newname for datafile  9 to
 "F:\ORA19BASE\ORADATA\IC\BB69D5F698D94116A5A55E7EEBEA2BA9\DATAFILE\O1_MF_SYSTEM_MBNM6P27_.DBF";
   set newname for datafile  10 to
 "F:\ORA19BASE\ORADATA\IC\BB69D5F698D94116A5A55E7EEBEA2BA9\DATAFILE\O1_MF_SYSAUX_MBNM6P2Q_.DBF";
   set newname for datafile  11 to
 "F:\ORA19BASE\ORADATA\IC\BB69D5F698D94116A5A55E7EEBEA2BA9\DATAFILE\O1_MF_UNDOTBS1_MBNM6P2Q_.DBF";
   set newname for datafile  12 to
 "F:\ORA19BASE\ORADATA\IC\BB69D5F698D94116A5A55E7EEBEA2BA9\DATAFILE\O1_MF_USERS_MBNM725D_.DBF";
   restore
   from  nonsparse   section size
 400 m   clone foreign pluggable database
    "PDB1"
   from service  'pega'   ;
}
executing Memory Script

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

Starting restore at 22-JAN-25
using channel ORA_AUX_DISK_1

channel ORA_AUX_DISK_1: starting datafile backup set restore
channel ORA_AUX_DISK_1: using network backup set from service pega
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_AUX_DISK_1: restoring section 1 of 2
channel ORA_AUX_DISK_1: restoring foreign file 9 to F:\ORA19BASE\ORADATA\IC\BB69D5F698D94116A5A55E7EEBEA2BA9\DATAFILE\O1_MF_SYSTEM_MBNM6P27_.DBF
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:07
channel ORA_AUX_DISK_1: starting datafile backup set restore
channel ORA_AUX_DISK_1: using network backup set from service pega
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_AUX_DISK_1: restoring section 2 of 2
channel ORA_AUX_DISK_1: restoring foreign file 9 to F:\ORA19BASE\ORADATA\IC\BB69D5F698D94116A5A55E7EEBEA2BA9\DATAFILE\O1_MF_SYSTEM_MBNM6P27_.DBF
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:01
channel ORA_AUX_DISK_1: starting datafile backup set restore
channel ORA_AUX_DISK_1: using network backup set from service pega
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_AUX_DISK_1: restoring section 1 of 2
channel ORA_AUX_DISK_1: restoring foreign file 10 to F:\ORA19BASE\ORADATA\IC\BB69D5F698D94116A5A55E7EEBEA2BA9\DATAFILE\O1_MF_SYSAUX_MBNM6P2Q_.DBF
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:07
channel ORA_AUX_DISK_1: starting datafile backup set restore
channel ORA_AUX_DISK_1: using network backup set from service pega
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_AUX_DISK_1: restoring section 2 of 2
channel ORA_AUX_DISK_1: restoring foreign file 10 to F:\ORA19BASE\ORADATA\IC\BB69D5F698D94116A5A55E7EEBEA2BA9\DATAFILE\O1_MF_SYSAUX_MBNM6P2Q_.DBF
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:01
channel ORA_AUX_DISK_1: starting datafile backup set restore
channel ORA_AUX_DISK_1: using network backup set from service pega
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_AUX_DISK_1: restoring section 1 of 1
channel ORA_AUX_DISK_1: restoring foreign file 11 to F:\ORA19BASE\ORADATA\IC\BB69D5F698D94116A5A55E7EEBEA2BA9\DATAFILE\O1_MF_UNDOTBS1_MBNM6P2Q_.DBF
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:03
channel ORA_AUX_DISK_1: starting datafile backup set restore
channel ORA_AUX_DISK_1: using network backup set from service pega
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_AUX_DISK_1: restoring section 1 of 1
channel ORA_AUX_DISK_1: restoring foreign file 12 to F:\ORA19BASE\ORADATA\IC\BB69D5F698D94116A5A55E7EEBEA2BA9\DATAFILE\O1_MF_USERS_MBNM725D_.DBF
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:01
Finished restore at 22-JAN-25

contents of Memory Script:
{
   set archivelog destination to  'F:\recovery';
   restore clone force from service  'pega'
           foreign archivelog from scn  13677955;
}
executing Memory Script

executing command: SET ARCHIVELOG DESTINATION

Starting restore at 22-JAN-25
using channel ORA_AUX_DISK_1

channel ORA_AUX_DISK_1: starting archived log restore to user-specified destination
archived log destination=F:\recovery
channel ORA_AUX_DISK_1: using network backup set from service pega
channel ORA_AUX_DISK_1: restoring archived log
archived log thread=1 sequence=120
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:01
channel ORA_AUX_DISK_1: starting archived log restore to user-specified destination
archived log destination=F:\recovery
channel ORA_AUX_DISK_1: using network backup set from service pega
channel ORA_AUX_DISK_1: restoring archived log
archived log thread=1 sequence=121
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:01
channel ORA_AUX_DISK_1: starting archived log restore to user-specified destination
archived log destination=F:\recovery
channel ORA_AUX_DISK_1: using network backup set from service pega
channel ORA_AUX_DISK_1: restoring archived log
archived log thread=1 sequence=122
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:01
Finished restore at 22-JAN-25

Performing import of metadata...
Finished Duplicate PDB at 22-JAN-25

Step 7. Confirm whether duplication succeeded.

On dest site:


f:\Oracle19c\bin>sqlplus sys as sysdba
SQL*Plus: Release 19.0.0.0.0 - Production on Wed Jan 22 10:04:00 2025
Version 19.23.0.0.0
Copyright (c) 1982, 2023, Oracle.  All rights reserved.
Enter password:
Connected to:
Oracle Database 19c Standard Edition 2 Release 19.0.0.0.0 - Production
Version 19.23.0.0.0

SQL> show pdbs

    CON_ID CON_NAME                       OPEN MODE  RESTRICTED
---------- ------------------------------ ---------- ----------
         2 PDB$SEED                       READ ONLY  NO
         3 ICPDB                          READ WRITE NO
         4 DEV                            READ WRITE YES

SQL> select con_id,name from v$datafile where con_id=4;
    CON_ID NAME
---------- ------------------------------------------------------------------------
         4 F:\ORA19BASE\ORADATA\IC\BB69D5F698D94116A5A55E7EEBEA2BA9\DATAFILE\O1_MF_SYSTEM_MBNM6P27_.DBF
         4 F:\ORA19BASE\ORADATA\IC\BB69D5F698D94116A5A55E7EEBEA2BA9\DATAFILE\O1_MF_SYSAUX_MBNM6P2Q_.DBF
         4 F:\ORA19BASE\ORADATA\IC\BB69D5F698D94116A5A55E7EEBEA2BA9\DATAFILE\O1_MF_UNDOTBS1_MBNM6P2Q_.DBF
         4 F:\ORA19BASE\ORADATA\IC\BB69D5F698D94116A5A55E7EEBEA2BA9\DATAFILE\O1_MF_USERS_MBNM725D_.DBF
Unknown's avatar

Author: SandeepSingh

Hi, I am working in IT industry with having more than 15 year of experience, worked as an Oracle DBA with a Company and handling different databases like Oracle, SQL Server , DB2 etc Worked as a Development and Database Administrator.

Leave a Reply

Discover more from SmartTechWays - Innovative Solutions for Smart Businesses

Subscribe now to keep reading and get access to the full archive.

Continue reading