Backup of a Container Database (CDB) and a Pluggable Database (PDB) Oracle in detail step by step

I am sharing the  are step-by-step instructions to backup a CDB and PDBs in Oracle to a custom location:

Database name:

SQL> select name from v$database;

NAME
---------
DB19


PDB name:

SQL> show pdbs

    CON_ID CON_NAME                       OPEN MODE  RESTRICTED
---------- ------------------------------ ---------- ----------
         2 PDB$SEED                       READ ONLY  NO
         3 PDB1                           READ WRITE NO


Database is on OCI VM DB system (DBCS). DB version is 19c

Create Backup  Directory

mkdir -p /u01/app/oracle/backup/DB19




Full CDB and PDB backup


A full backup of the CDB you are also doing a full backup of all PDBs.


RMAN> connect target sys/Sfbn-Dv123#@DB19_PRIMY;
Allocate channels with custom format:

run{
allocate channel ch1 type disk format '/u01/app/oracle/backup/%d/db_backup_%U';
allocate channel ch2 type disk format '/u01/app/oracle/backup/%d/db_backup_%U';
backup database plus archivelog;
release channel ch1;
release channel ch2;
}

Output:
[oracle@foadb backup]$ rman target /

Recovery Manager: Release 19.0.0.0.0 - Production on Sun Dec 31 16:49:31 2023
Version 19.21.0.0.0

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

connected to target database: DB19 (DBID=888209347)

RMAN> run{
allocate channel ch1 type disk format '/u01/app/oracle/backup/%d/db_backup_%U';
allocate channel ch2 type disk format '/u01/app/oracle/backup/%d/db_backup_%U';
backup database plus archivelog;
release channel ch1;
release channel ch2;
}
2> 3> 4> 5> 6> 7> 
using target database control file instead of recovery catalog
allocated channel: ch1
channel ch1: SID=66 device type=DISK

allocated channel: ch2
channel ch2: SID=220 device type=DISK


Starting backup at 31-DEC-23
current log archived
channel ch1: starting archived log backup set
channel ch1: specifying archived log(s) in backup set
input archived log thread=1 sequence=2 RECID=1 STAMP=1157042730
channel ch1: starting piece 1 at 31-DEC-23
channel ch2: starting archived log backup set
channel ch2: specifying archived log(s) in backup set
input archived log thread=1 sequence=3 RECID=2 STAMP=1157042857
input archived log thread=1 sequence=4 RECID=3 STAMP=1157042997
channel ch2: starting piece 1 at 31-DEC-23
channel ch2: finished piece 1 at 31-DEC-23
piece handle=/u01/app/oracle/backup/DB19/db_backup_072fe4pm_7_1_1 tag=TAG20231231T164958 comment=NONE
channel ch2: backup set complete, elapsed time: 00:00:01
channel ch1: finished piece 1 at 31-DEC-23
piece handle=/u01/app/oracle/backup/DB19/db_backup_062fe4pm_6_1_1 tag=TAG20231231T164958 comment=NONE
channel ch1: backup set complete, elapsed time: 00:00:07
Finished backup at 31-DEC-23

Starting backup at 31-DEC-23
channel ch1: starting full datafile backup set
channel ch1: specifying datafile(s) in backup set
input datafile file number=00001 name=+DATA/DB19_PRIMY/DATAFILE/system.261.1156994113
input datafile file number=00011 name=+DATA/DB19_PRIMY/DATAFILE/users.269.1156995421
channel ch1: starting piece 1 at 31-DEC-23
channel ch2: starting full datafile backup set
channel ch2: specifying datafile(s) in backup set
input datafile file number=00003 name=+DATA/DB19_PRIMY/DATAFILE/sysaux.268.1156994091
input datafile file number=00004 name=+DATA/DB19_PRIMY/DATAFILE/undotbs1.260.1156994147
channel ch2: starting piece 1 at 31-DEC-23
channel ch2: finished piece 1 at 31-DEC-23
piece handle=/u01/app/oracle/backup/DB19/db_backup_092fe4pu_9_1_1 tag=TAG20231231T165006 comment=NONE
channel ch2: backup set complete, elapsed time: 00:00:16
channel ch2: starting full datafile backup set
channel ch2: specifying datafile(s) in backup set
input datafile file number=00008 name=+DATA/DB19_PRIMY/0DC6D840E24B49E0E063C902000A877F/DATAFILE/system.273.1156994903
input datafile file number=00010 name=+DATA/DB19_PRIMY/0DC6D840E24B49E0E063C902000A877F/DATAFILE/undotbs1.270.1156994937
channel ch2: starting piece 1 at 31-DEC-23
channel ch1: finished piece 1 at 31-DEC-23
piece handle=/u01/app/oracle/backup/DB19/db_backup_082fe4pu_8_1_1 tag=TAG20231231T165006 comment=NONE
channel ch1: backup set complete, elapsed time: 00:00:19
channel ch1: starting full datafile backup set
channel ch1: specifying datafile(s) in backup set
input datafile file number=00006 name=+DATA/DB19_PRIMY/06FD4ED1E69F9D96E0639902F40A045F/DATAFILE/sysaux.265.1156993591
input datafile file number=00007 name=+DATA/DB19_PRIMY/06FD4ED1E69F9D96E0639902F40A045F/DATAFILE/undotbs1.266.1156993591
channel ch1: starting piece 1 at 31-DEC-23
channel ch1: finished piece 1 at 31-DEC-23
piece handle=/u01/app/oracle/backup/DB19/db_backup_0b2fe4qh_11_1_1 tag=TAG20231231T165006 comment=NONE
channel ch1: backup set complete, elapsed time: 00:00:07
channel ch1: starting full datafile backup set
channel ch1: specifying datafile(s) in backup set
input datafile file number=00005 name=+DATA/DB19_PRIMY/06FD4ED1E69F9D96E0639902F40A045F/DATAFILE/system.264.1156993591
channel ch1: starting piece 1 at 31-DEC-23
channel ch2: finished piece 1 at 31-DEC-23
piece handle=/u01/app/oracle/backup/DB19/db_backup_0a2fe4qe_10_1_1 tag=TAG20231231T165006 comment=NONE
channel ch2: backup set complete, elapsed time: 00:00:11
channel ch2: starting full datafile backup set
channel ch2: specifying datafile(s) in backup set
input datafile file number=00009 name=+DATA/DB19_PRIMY/0DC6D840E24B49E0E063C902000A877F/DATAFILE/sysaux.271.1156994923
input datafile file number=00012 name=+DATA/DB19_PRIMY/0DC6D840E24B49E0E063C902000A877F/DATAFILE/users.274.1156995421
channel ch2: starting piece 1 at 31-DEC-23
channel ch1: finished piece 1 at 31-DEC-23
piece handle=/u01/app/oracle/backup/DB19/db_backup_0c2fe4qp_12_1_1 tag=TAG20231231T165006 comment=NONE
channel ch1: backup set complete, elapsed time: 00:00:07
channel ch2: finished piece 1 at 31-DEC-23
piece handle=/u01/app/oracle/backup/DB19/db_backup_0d2fe4qp_13_1_1 tag=TAG20231231T165006 comment=NONE
channel ch2: backup set complete, elapsed time: 00:00:07
Finished backup at 31-DEC-23

Starting backup at 31-DEC-23
current log archived
channel ch1: starting archived log backup set
channel ch1: specifying archived log(s) in backup set
input archived log thread=1 sequence=5 RECID=4 STAMP=1157043040
channel ch1: starting piece 1 at 31-DEC-23
channel ch1: finished piece 1 at 31-DEC-23
piece handle=/u01/app/oracle/backup/DB19/db_backup_0e2fe4r1_14_1_1 tag=TAG20231231T165041 comment=NONE
channel ch1: backup set complete, elapsed time: 00:00:01
Finished backup at 31-DEC-23

Starting Control File and SPFILE Autobackup at 31-DEC-23
piece handle=+RECO/DB19_PRIMY/AUTOBACKUP/2023_12_31/s_1157043042.266.1157043043 comment=NONE
Finished Control File and SPFILE Autobackup at 31-DEC-23

released channel: ch1

released channel: ch2


Root Container backup


A backup of the root container is a backup of the CDB, excluding any of the PDBs.


run{
allocate channel ch1 type disk format '/u01/app/oracle/backup/%d/root_backup_%U';
allocate channel ch2 type disk format '/u01/app/oracle/backup/%d/root_backup_%U';
backup database root;
release channel ch1;
release channel ch2;
}


Output:

[oracle@foadb DB19]$ rman target /

Recovery Manager: Release 19.0.0.0.0 - Production on Sun Dec 31 16:57:06 2023
Version 19.21.0.0.0

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

connected to target database: DB19 (DBID=888209347)

RMAN> run{
allocate channel ch1 type disk format '/u01/app/oracle/backup/%d/root_backup_%U';
allocate channel ch2 type disk format '/u01/app/oracle/backup/%d/root_backup_%U';
backup database root;
release channel ch1;
release channel ch2;
}
2> 3> 4> 5> 6> 7> 
using target database control file instead of recovery catalog
allocated channel: ch1
channel ch1: SID=39 device type=DISK

allocated channel: ch2
channel ch2: SID=223 device type=DISK

Starting backup at 31-DEC-23
channel ch1: starting full datafile backup set
channel ch1: specifying datafile(s) in backup set
input datafile file number=00001 name=+DATA/DB19_PRIMY/DATAFILE/system.261.1156994113
input datafile file number=00011 name=+DATA/DB19_PRIMY/DATAFILE/users.269.1156995421
channel ch1: starting piece 1 at 31-DEC-23
channel ch2: starting full datafile backup set
channel ch2: specifying datafile(s) in backup set
input datafile file number=00003 name=+DATA/DB19_PRIMY/DATAFILE/sysaux.268.1156994091
input datafile file number=00004 name=+DATA/DB19_PRIMY/DATAFILE/undotbs1.260.1156994147
channel ch2: starting piece 1 at 31-DEC-23
channel ch1: finished piece 1 at 31-DEC-23
piece handle=/u01/app/oracle/backup/DB19/root_backup_0g2fe57o_16_1_1 tag=TAG20231231T165728 comment=NONE
channel ch1: backup set complete, elapsed time: 00:00:25
channel ch2: finished piece 1 at 31-DEC-23
piece handle=/u01/app/oracle/backup/DB19/root_backup_0h2fe57q_17_1_1 tag=TAG20231231T165728 comment=NONE
channel ch2: backup set complete, elapsed time: 00:00:25
Finished backup at 31-DEC-23

Starting Control File and SPFILE Autobackup at 31-DEC-23
piece handle=+RECO/DB19_PRIMY/AUTOBACKUP/2023_12_31/s_1157043475.267.1157043475 comment=NONE
Finished Control File and SPFILE Autobackup at 31-DEC-23

released channel: ch1

released channel: ch2

Pluggable Database Backup


We can take backup of individual pdb's. 

run{
allocate channel ch1 type disk format '/u01/app/oracle/backup/%d/PDB1_backup_%U';
allocate channel ch2 type disk format '/u01/app/oracle/backup/%d/PDB1_backup_%U';
backup pluggable database pdb1;
release channel ch1;
release channel ch2;
}

Output:

[oracle@foadb DB19]$ rman target /

Recovery Manager: Release 19.0.0.0.0 - Production on Sun Dec 31 17:02:17 2023
Version 19.21.0.0.0

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

connected to target database: DB19 (DBID=888209347)

RMAN> run{
allocate channel ch1 type disk format '/u01/app/oracle/backup/%d/PDB1_backup_%U';
allocate channel ch2 type disk format '/u01/app/oracle/backup/%d/PDB1_backup_%U';
backup pluggable database pdb1;
release channel ch1;
release channel ch2;
}
2> 3> 4> 5> 6> 7> 
using target database control file instead of recovery catalog
allocated channel: ch1
channel ch1: SID=66 device type=DISK

allocated channel: ch2
channel ch2: SID=220 device type=DISK

Starting backup at 31-DEC-23
channel ch1: starting full datafile backup set
channel ch1: specifying datafile(s) in backup set
input datafile file number=00008 name=+DATA/DB19_PRIMY/0DC6D840E24B49E0E063C902000A877F/DATAFILE/system.273.1156994903
input datafile file number=00010 name=+DATA/DB19_PRIMY/0DC6D840E24B49E0E063C902000A877F/DATAFILE/undotbs1.270.1156994937
channel ch1: starting piece 1 at 31-DEC-23
channel ch2: starting full datafile backup set
channel ch2: specifying datafile(s) in backup set
input datafile file number=00009 name=+DATA/DB19_PRIMY/0DC6D840E24B49E0E063C902000A877F/DATAFILE/sysaux.271.1156994923
input datafile file number=00012 name=+DATA/DB19_PRIMY/0DC6D840E24B49E0E063C902000A877F/DATAFILE/users.274.1156995421
channel ch2: starting piece 1 at 31-DEC-23
channel ch1: finished piece 1 at 31-DEC-23
piece handle=/u01/app/oracle/backup/DB19/PDB1_backup_0j2fe5hj_19_1_1 tag=TAG20231231T170243 comment=NONE
channel ch1: backup set complete, elapsed time: 00:00:07
channel ch2: finished piece 1 at 31-DEC-23
piece handle=/u01/app/oracle/backup/DB19/PDB1_backup_0k2fe5hj_20_1_1 tag=TAG20231231T170243 comment=NONE
channel ch2: backup set complete, elapsed time: 00:00:07
Finished backup at 31-DEC-23

Starting Control File and SPFILE Autobackup at 31-DEC-23
piece handle=+RECO/DB19_PRIMY/AUTOBACKUP/2023_12_31/s_1157043771.268.1157043771 comment=NONE
Finished Control File and SPFILE Autobackup at 31-DEC-23

released channel: ch1

released channel: ch2




If you like please follow and comment