Starting with Oracle 12c, we have a new "layer", some new concepts were introduced like Container Database, Pluggable Database, PDB SEED, Root, etc. Before 12c, in order to do backups and restores all what we had to do is to open a connection to the database where we will work and start working with our RMAN stuff. But now we have the new layer: Pluggable Database (PDB). Now there are two ways to work with backups and restores, we can work from CDB$ROOT and then use the new clauses inside RMAN in order to identify the PDB and its element, for example the datafile No. 3 of the PDB "GUATEMALAPDB"; and also we can connect directly to the PDB where we will work. In this article we will go through all these tasks and we will perform backups and restores from both paces, CDB$ROOT and an specific PDB. This is the overview of our work: Backup from CDB Root Backup of a datafile Backup of a tablespace backup of a PDB Backup of the CDB$ROOT Backup from PDB Backup of a datafile Backup of a tablespace Backup of the PDB Restore from CDB Root Restore of a datafile Restore of a tablespace Restore of a PDB Restore the CDB$ROOT Restore from PDB Restore of a datafile Restore of a tablespace Restore of the PDB The environment that I will use has 2 Pluggable Databases (PDB1 and PDB2): SQL> select con_id, name from v$pdbs; CON_ID NAME ---------- ------------------------------ 2 PDB$SEED 3 PDB1 4 PDB2 The location of the datafiles, its ID and so on are the following: SQL> select con_id, file#, name from v$datafile order by 1,2 CON_ID FILE NAME -------- ------- ------------------------------------------------------------ 1 1 /data/cdb/system01.dbf 1 3 /data/cdb/sysaux01.dbf 1 4 /data/cdb/undotbs01.dbf 1 6 /data/cdb/users01.dbf 2 5 /data/cdb/pdbseed/system01.dbf 2 7 /data/cdb/pdbseed/sysaux01.dbf 3 8 /data/seed/cdb/pdbseed/system01.dbf 3 9 /data/seed/cdb/pdbseed/sysaux01.dbf 4 10 /data/system01.dbf 4 11 /data/sysaux01.dbf 10 rows selected. Backup from CDB Root Backup of a datafile When you are doing a backup of a datafile while connected to CDB$ROOT you don't have to specify any clause to name the PDB of this datafile is part of. Every datafile into the Container Database (CDB) has the "FILE_ID" or "FILE#" unique in the whole CDB. So all what you have to know in order to backup a datafile of a PDB is its file identifier: Example: Do a backup of the datafile 9 that is part of tablespace SYSAUX in the PDB "PDB1": RMAN> backup datafile 9; Starting backup at 01-MAY-16 using channel ORA_DISK_1 channel ORA_DISK_1: starting full datafile backup set channel ORA_DISK_1: specifying datafile(s) in backup set input datafile file number=00009 name=/data/seed/cdb/pdbseed/sysaux01.dbf channel ORA_DISK_1: starting piece 1 at 01-MAY-16 channel ORA_DISK_1: finished piece 1 at 01-MAY-16 piece handle=/data/CDB/30D4BFFA4CFE3ED0E053047111ACC580/backupset/2016_05_01/o1_mf_nnndf_TAG20160501T160415_cldr9z85_.bkp tag=TAG20160501T160415 comment=NONE channel ORA_DISK_1: backup set complete, elapsed time: 00:00:07 Finished backup at 01-MAY-16 Starting Control File and SPFILE Autobackup at 01-MAY-16 piece handle=/data/CDB/autobackup/2016_05_01/o1_mf_s_910713862_cldrb6hs_.bkp comment=NONE Finished Control File and SPFILE Autobackup at 01-MAY-16 RMAN> Backup of a tablespace To backup tablespaces, you can name the PDB that the tablespace is part of, followed by ":" and then the name of the tablespace: [PDB_NAME]:[TABLESPACE_NAME] Example: Do a backup of tablespace SYSAUX of PDB "PDB1": RMAN> backup tablespace PDB1:SYSAUX; Starting backup at 01-MAY-16 using channel ORA_DISK_1 channel ORA_DISK_1: starting full datafile backup set channel ORA_DISK_1: specifying datafile(s) in backup set input datafile file number=00009 name=/data/seed/cdb/pdbseed/sysaux01.dbf channel ORA_DISK_1: starting piece 1 at 01-MAY-16 channel ORA_DISK_1: finished piece 1 at 01-MAY-16 piece handle=/data/CDB/30D4BFFA4CFE3ED0E053047111ACC580/backupset/2016_05_01/o1_mf_nnndf_TAG20160501T160601_cldrf9l1_.bkp tag=TAG20160501T160601 comment=NONE channel ORA_DISK_1: backup set complete, elapsed time: 00:00:07 Finished backup at 01-MAY-16 Starting Control File and SPFILE Autobackup at 01-MAY-16 piece handle=/data/CDB/autobackup/2016_05_01/o1_mf_s_910713968_cldrfjs0_.bkp comment=NONE Finished Control File and SPFILE Autobackup at 01-MAY-16 RMAN> Backup of a PDB To do backups of Pluggable Databases, you can use the new clause "Backup Pluggable Database" from RMAN, and then specify the name of the PDB Example: Backup the PDB "PDB1": RMAN> backup pluggable database PDB1; Starting backup at 01-MAY-16 using channel ORA_DISK_1 channel ORA_DISK_1: starting full datafile backup set channel ORA_DISK_1: specifying datafile(s) in backup set input datafile file number=00009 name=/data/seed/cdb/pdbseed/sysaux01.dbf input datafile file number=00008 name=/data/seed/cdb/pdbseed/system01.dbf channel ORA_DISK_1: starting piece 1 at 01-MAY-16 channel ORA_DISK_1: finished piece 1 at 01-MAY-16 piece handle=/data/CDB/30D4BFFA4CFE3ED0E053047111ACC580/backupset/2016_05_01/o1_mf_nnndf_TAG20160501T160758_cldrjypv_.bkp tag=TAG20160501T160758 comment=NONE channel ORA_DISK_1: backup set complete, elapsed time: 00:00:15 Finished backup at 01-MAY-16 Starting Control File and SPFILE Autobackup at 01-MAY-16 piece handle=/data/CDB/autobackup/2016_05_01/o1_mf_s_910714093_cldrkg04_.bkp comment=NONE Finished Control File and SPFILE Autobackup at 01-MAY-16 You can also use the same clause that you have been using until before 12c "backup database", followed by the database name: RMAN> backup database pdb2; Starting backup at 01-MAY-16 using channel ORA_DISK_1 channel ORA_DISK_1: starting full datafile backup set channel ORA_DISK_1: specifying datafile(s) in backup set input datafile file number=00011 name=/data/sysaux01.dbf input datafile file number=00010 name=/data/system01.dbf channel ORA_DISK_1: starting piece 1 at 01-MAY-16 channel ORA_DISK_1: finished piece 1 at 01-MAY-16 piece handle=/data/CDB/30D4E481E7224175E053047111ACB0BA/backupset/2016_05_01/o1_mf_nnndf_TAG20160501T173357_cldxl5vb_.bkp tag=TAG20160501T173357 comment=NONE channel ORA_DISK_1: backup set complete, elapsed time: 00:00:07 Finished backup at 01-MAY-16 Starting Control File and SPFILE Autobackup at 01-MAY-16 piece handle=/data/CDB/autobackup/2016_05_01/o1_mf_s_910719245_cldxlf37_.bkp comment=NONE Finished Control File and SPFILE Autobackup at 01-MAY-16 Backup of the CDB$ROOT the CDB$ROOT is also a container, based on that, as a container you should use the same clause "backup database" followed by the name "root": RMAN> backup database root; Starting backup at 01-MAY-16 using target database control file instead of recovery catalog allocated channel: ORA_DISK_1 channel ORA_DISK_1: SID=78 device type=DISK channel ORA_DISK_1: starting full datafile backup set channel ORA_DISK_1: specifying datafile(s) in backup set input datafile file number=00001 name=/data/cdb/system01.dbf input datafile file number=00003 name=/data/cdb/sysaux01.dbf input datafile file number=00004 name=/data/cdb/undotbs01.dbf input datafile file number=00006 name=/data/cdb/users01.dbf channel ORA_DISK_1: starting piece 1 at 01-MAY-16 channel ORA_DISK_1: finished piece 1 at 01-MAY-16 piece handle=/data/CDB/backupset/2016_05_01/o1_mf_nnndf_TAG20160501T173316_cldxjwgz_.bkp tag=TAG20160501T173316 comment=NONE channel ORA_DISK_1: backup set complete, elapsed time: 00:00:15 Finished backup at 01-MAY-16 Starting Control File and SPFILE Autobackup at 01-MAY-16 piece handle=/data/CDB/autobackup/2016_05_01/o1_mf_s_910719211_cldxkcnx_.bkp comment=NONE Finished Control File and SPFILE Autobackup at 01-MAY-16 Backup from PDB When you are connected directly to the PDB where you will perform the backup it is exactly the same that if you were connected to a 11g database, that's why we will not provide more comments because the procedure is the same than whatever database backup datafile 10; Starting backup at 01-MAY-16 allocated channel: ORA_DISK_1 channel ORA_DISK_1: SID=42 device type=DISK channel ORA_DISK_1: starting full datafile backup set channel ORA_DISK_1: specifying datafile(s) in backup set input datafile file number=00010 name=/data/system01.dbf channel ORA_DISK_1: starting piece 1 at 01-MAY-16 channel ORA_DISK_1: finished piece 1 at 01-MAY-16 piece handle=/data/CDB/30D4E481E7224175E053047111ACB0BA/backupset/2016_05_01/o1_mf_nnndf_TAG20160501T172849_cldx8k7n_.bkp tag=TAG20160501T172849 comment=NONE channel ORA_DISK_1: backup set complete, elapsed time: 00:00:03 Finished backup at 01-MAY-16 Starting Control File and SPFILE Autobackup at 01-MAY-16 piece handle=/data/CDB/autobackup/2016_05_01/o1_mf_s_910718932_cldx8njt_.bkp comment=NONE Finished Control File and SPFILE Autobackup at 01-MAY-16 Using datafile name: RMAN> backup datafile '/data/system01.dbf'; Starting backup at 01-MAY-16 using channel ORA_DISK_1 channel ORA_DISK_1: starting full datafile backup set channel ORA_DISK_1: specifying datafile(s) in backup set input datafile file number=00010 name=/data/system01.dbf channel ORA_DISK_1: starting piece 1 at 01-MAY-16 channel ORA_DISK_1: finished piece 1 at 01-MAY-16 piece handle=/data/CDB/30D4E481E7224175E053047111ACB0BA/backupset/2016_05_01/o1_mf_nnndf_TAG20160501T172926_cldx9pmx_.bkp tag=TAG20160501T172926 comment=NONE channel ORA_DISK_1: backup set complete, elapsed time: 00:00:03 Finished backup at 01-MAY-16 Starting Control File and SPFILE Autobackup at 01-MAY-16 piece handle=/data/CDB/autobackup/2016_05_01/o1_mf_s_910718969_cldx9srg_.bkp comment=NONE Finished Control File and SPFILE Autobackup at 01-MAY-16 Backup of a tablespace As you can see below, now you do not have to specify the name of the pluggable database that the tablespace is part of: RMAN> backup tablespace sysaux; Starting backup at 01-MAY-16 using channel ORA_DISK_1 channel ORA_DISK_1: starting full datafile backup set channel ORA_DISK_1: specifying datafile(s) in backup set input datafile file number=00011 name=/data/sysaux01.dbf channel ORA_DISK_1: starting piece 1 at 01-MAY-16 channel ORA_DISK_1: finished piece 1 at 01-MAY-16 piece handle=/data/CDB/30D4E481E7224175E053047111ACB0BA/backupset/2016_05_01/o1_mf_nnndf_TAG20160501T173000_cldxbrtl_.bkp tag=TAG20160501T173000 comment=NONE channel ORA_DISK_1: backup set complete, elapsed time: 00:00:07 Finished backup at 01-MAY-16 Starting Control File and SPFILE Autobackup at 01-MAY-16 piece handle=/data/CDB/autobackup/2016_05_01/o1_mf_s_910719007_cldxc009_.bkp comment=NONE Finished Control File and SPFILE Autobackup at 01-MAY-16 RMAN> Backup of the PDB RMAN> backup database; Starting backup at 01-MAY-16 using channel ORA_DISK_1 channel ORA_DISK_1: starting full datafile backup set channel ORA_DISK_1: specifying datafile(s) in backup set input datafile file number=00011 name=/data/sysaux01.dbf input datafile file number=00010 name=/data/system01.dbf channel ORA_DISK_1: starting piece 1 at 01-MAY-16 channel ORA_DISK_1: finished piece 1 at 01-MAY-16 piece handle=/data/CDB/30D4E481E7224175E053047111ACB0BA/backupset/2016_05_01/o1_mf_nnndf_TAG20160501T173019_cldxccqd_.bkp tag=TAG20160501T173019 comment=NONE channel ORA_DISK_1: backup set complete, elapsed time: 00:00:15 Finished backup at 01-MAY-16 Starting Control File and SPFILE Autobackup at 01-MAY-16 piece handle=/data/CDB/autobackup/2016_05_01/o1_mf_s_910719034_cldxctvm_.bkp comment=NONE Finished Control File and SPFILE Autobackup at 01-MAY-16 RMAN> Restore from CDB Root As we discussed on the backup section, the backups of a specific datafile is performed by its ID or by its name, the name of the pluggable database is not the identifier: Restore of a datafile [oracle@db12102 ~]$ rman target / RMAN> restore datafile 10; Starting restore at 01-MAY-16 allocated channel: ORA_DISK_1 channel ORA_DISK_1: SID=23 device type=DISK channel ORA_DISK_1: starting datafile backup set restore channel ORA_DISK_1: specifying datafile(s) to restore from backup set channel ORA_DISK_1: restoring datafile 00010 to /data/system01.dbf channel ORA_DISK_1: reading from backup piece /data/CDB/30D4E481E7224175E053047111ACB0BA/backupset/2016_05_01/o1_mf_nnndf_TAG20160501T173357_cldxl5vb_.bkp channel ORA_DISK_1: piece handle=/data/CDB/30D4E481E7224175E053047111ACB0BA/backupset/2016_05_01/o1_mf_nnndf_TAG20160501T173357_cldxl5vb_.bkp tag=TAG20160501T173357 channel ORA_DISK_1: restored backup piece 1 channel ORA_DISK_1: restore complete, elapsed time: 00:00:03 Finished restore at 01-MAY-16 You can also use the datafile name: RMAN> restore datafile '/data/system01.dbf'; Starting restore at 01-MAY-16 using channel ORA_DISK_1 channel ORA_DISK_1: starting datafile backup set restore channel ORA_DISK_1: specifying datafile(s) to restore from backup set channel ORA_DISK_1: restoring datafile 00010 to /data/system01.dbf channel ORA_DISK_1: reading from backup piece /data/CDB/30D4E481E7224175E053047111ACB0BA/backupset/2016_05_01/o1_mf_nnndf_TAG20160501T173357_cldxl5vb_.bkp channel ORA_DISK_1: piece handle=/data/CDB/30D4E481E7224175E053047111ACB0BA/backupset/2016_05_01/o1_mf_nnndf_TAG20160501T173357_cldxl5vb_.bkp tag=TAG20160501T173357 channel ORA_DISK_1: restored backup piece 1 channel ORA_DISK_1: restore complete, elapsed time: 00:00:03 Finished restore at 01-MAY-16 RMAN> Restore of a tablespace While restoring a tablespace is different, for tablespaces you have to specify to which pluggable database this tablespace is part of: [oracle@db12102 ~]$ rman target / RMAN> restore tablespace pdb2:sysaux; Starting restore at 01-MAY-16 using channel ORA_DISK_1 channel ORA_DISK_1: starting datafile backup set restore channel ORA_DISK_1: specifying datafile(s) to restore from backup set channel ORA_DISK_1: restoring datafile 00011 to /data/sysaux01.dbf channel ORA_DISK_1: reading from backup piece /data/CDB/30D4E481E7224175E053047111ACB0BA/backupset/2016_05_01/o1_mf_nnndf_TAG20160501T173357_cldxl5vb_.bkp channel ORA_DISK_1: piece handle=/data/CDB/30D4E481E7224175E053047111ACB0BA/backupset/2016_05_01/o1_mf_nnndf_TAG20160501T173357_cldxl5vb_.bkp tag=TAG20160501T173357 channel ORA_DISK_1: restored backup piece 1 channel ORA_DISK_1: restore complete, elapsed time: 00:00:07 Finished restore at 01-MAY-16 Restore of a PDB You can use the clause "restore pluggable database" followed of the PDB name: [oracle@db12102 ~]$ rman target / RMAN> restore pluggable database pdb1; Starting restore at 01-MAY-16 using channel ORA_DISK_1 channel ORA_DISK_1: starting datafile backup set restore channel ORA_DISK_1: specifying datafile(s) to restore from backup set channel ORA_DISK_1: restoring datafile 00008 to /data/seed/cdb/pdbseed/system01.dbf channel ORA_DISK_1: restoring datafile 00009 to /data/seed/cdb/pdbseed/sysaux01.dbf channel ORA_DISK_1: reading from backup piece /data/CDB/30D4BFFA4CFE3ED0E053047111ACC580/backupset/2016_05_01/o1_mf_nnndf_TAG20160501T173344_cldxks19_.bkp channel ORA_DISK_1: piece handle=/data/CDB/30D4BFFA4CFE3ED0E053047111ACC580/backupset/2016_05_01/o1_mf_nnndf_TAG20160501T173344_cldxks19_.bkp tag=TAG20160501T173344 channel ORA_DISK_1: restored backup piece 1 channel ORA_DISK_1: restore complete, elapsed time: 00:00:07 Finished restore at 01-MAY-16 You can also use the clause "restore database" followed by the database name: RMAN> restore database pdb1; Starting restore at 01-MAY-16 using channel ORA_DISK_1 channel ORA_DISK_1: starting datafile backup set restore channel ORA_DISK_1: specifying datafile(s) to restore from backup set channel ORA_DISK_1: restoring datafile 00008 to /data/seed/cdb/pdbseed/system01.dbf channel ORA_DISK_1: restoring datafile 00009 to /data/seed/cdb/pdbseed/sysaux01.dbf channel ORA_DISK_1: reading from backup piece /data/CDB/30D4BFFA4CFE3ED0E053047111ACC580/backupset/2016_05_01/o1_mf_nnndf_TAG20160501T173344_cldxks19_.bkp channel ORA_DISK_1: piece handle=/data/CDB/30D4BFFA4CFE3ED0E053047111ACC580/backupset/2016_05_01/o1_mf_nnndf_TAG20160501T173344_cldxks19_.bkp tag=TAG20160501T173344 channel ORA_DISK_1: restored backup piece 1 channel ORA_DISK_1: restore complete, elapsed time: 00:00:08 Finished restore at 01-MAY-16 RMAN> Restore the CDB$ROOT: RMAN> restore database root; Starting restore at 01-MAY-16 using target database control file instead of recovery catalog allocated channel: ORA_DISK_1 channel ORA_DISK_1: SID=7 device type=DISK channel ORA_DISK_1: starting datafile backup set restore channel ORA_DISK_1: specifying datafile(s) to restore from backup set channel ORA_DISK_1: restoring datafile 00001 to /data/cdb/system01.dbf channel ORA_DISK_1: restoring datafile 00003 to /data/cdb/sysaux01.dbf channel ORA_DISK_1: restoring datafile 00004 to /data/cdb/undotbs01.dbf channel ORA_DISK_1: restoring datafile 00006 to /data/cdb/users01.dbf channel ORA_DISK_1: reading from backup piece /data/CDB/backupset/2016_05_01/o1_mf_nnndf_TAG20160501T173316_cldxjwgz_.bkp channel ORA_DISK_1: piece handle=/data/CDB/backupset/2016_05_01/o1_mf_nnndf_TAG20160501T173316_cldxjwgz_.bkp tag=TAG20160501T173316 channel ORA_DISK_1: restored backup piece 1 channel ORA_DISK_1: restore complete, elapsed time: 00:00:25 Finished restore at 01-MAY-16 Restore from PDB Restoring datafiles, tablespaces and a PDB is exactly the same than before 12c, since you are connected directly to the PDB: Restore of a datafile [oracle@db12102 ~]$ rman target sys/Manager1@192.168.1.4:1521/pdb2 RMAN> restore datafile 10; Starting restore at 01-MAY-16 using channel ORA_DISK_1 channel ORA_DISK_1: starting datafile backup set restore channel ORA_DISK_1: specifying datafile(s) to restore from backup set channel ORA_DISK_1: restoring datafile 00010 to /data/system01.dbf channel ORA_DISK_1: reading from backup piece /data/CDB/30D4E481E7224175E053047111ACB0BA/backupset/2016_05_01/o1_mf_nnndf_TAG20160501T173357_cldxl5vb_.bkp channel ORA_DISK_1: piece handle=/data/CDB/30D4E481E7224175E053047111ACB0BA/backupset/2016_05_01/o1_mf_nnndf_TAG20160501T173357_cldxl5vb_.bkp tag=TAG20160501T173357 channel ORA_DISK_1: restored backup piece 1 channel ORA_DISK_1: restore complete, elapsed time: 00:00:03 Finished restore at 01-MAY-16 RMAN> Restore of a tablespace [oracle@db12102 ~]$ rman target sys/Manager1@192.168.1.4:1521/pdb2 RMAN> restore tablespace sysaux; Starting restore at 01-MAY-16 using target database control file instead of recovery catalog allocated channel: ORA_DISK_1 channel ORA_DISK_1: SID=39 device type=DISK channel ORA_DISK_1: starting datafile backup set restore channel ORA_DISK_1: specifying datafile(s) to restore from backup set channel ORA_DISK_1: restoring datafile 00011 to /data/sysaux01.dbf channel ORA_DISK_1: reading from backup piece /data/CDB/30D4E481E7224175E053047111ACB0BA/backupset/2016_05_01/o1_mf_nnndf_TAG20160501T173357_cldxl5vb_.bkp channel ORA_DISK_1: piece handle=/data/CDB/30D4E481E7224175E053047111ACB0BA/backupset/2016_05_01/o1_mf_nnndf_TAG20160501T173357_cldxl5vb_.bkp tag=TAG20160501T173357 channel ORA_DISK_1: restored backup piece 1 channel ORA_DISK_1: restore complete, elapsed time: 00:00:07 Finished restore at 01-MAY-16 Restore of the PDB [oracle@db12102 ~]$ rman target sys/Manager1@192.168.1.4:1521/pdb2 RMAN> restore database; Starting restore at 01-MAY-16 using channel ORA_DISK_1 channel ORA_DISK_1: starting datafile backup set restore channel ORA_DISK_1: specifying datafile(s) to restore from backup set channel ORA_DISK_1: restoring datafile 00010 to /data/system01.dbf channel ORA_DISK_1: restoring datafile 00011 to /data/sysaux01.dbf channel ORA_DISK_1: reading from backup piece /data/CDB/30D4E481E7224175E053047111ACB0BA/backupset/2016_05_01/o1_mf_nnndf_TAG20160501T173357_cldxl5vb_.bkp channel ORA_DISK_1: piece handle=/data/CDB/30D4E481E7224175E053047111ACB0BA/backupset/2016_05_01/o1_mf_nnndf_TAG20160501T173357_cldxl5vb_.bkp tag=TAG20160501T173357 channel ORA_DISK_1: restored backup piece 1 channel ORA_DISK_1: restore complete, elapsed time: 00:00:07 Finished restore at 01-MAY-16 Follow me:
↧