This was first published on https://blog.dbi-services.com/12cr2-partial-pdb-backup (2017-05-01)
Republishing here for new followers. The content is related to the the versions available at the publication date
I had a recent question about the following mention from the 12cR2 Multitenant book, about Partial PDB backups: . Here is an example in 12.2 with local undo to illustrate the answer, which may help to understand what is a partial PDB backup. Of course, since 12cR1 you can backup PDB individually, without the CDB$ROOT, in the same way you can backup only a few tablespaces subset of a CDB. It can be part of your backup strategy, but it is not to be considered as a backup that you can restore elsewhere later. A PDB is not self-consistent without the PDB$ROOT except if is has been closed and unplugged. In 12.1 you cannot restore a partial PDB backup if you don’t have the CDB$ROOT at the same point in time, because the recovery phase will need to rollback the ongoing transactions, and this requires to have the UNDO tablespace recovered at the same point in time.
However, in 12.2 with LOCAL UNDO, the partial PDB backup contains the local UNDO tablespace and then it can be sufficient to do a PDB Point In Time Recovery within the same CDB. And, in this case only, it is not required to have a backup of the root.
Let’s test it. I explicitly delete all backups
Recovery Manager: Release 12.2.0.1.0 - Production on Sun Apr 30 22:11:38 2017 Copyright (c) 1982, 2017, Oracle and/or its affiliates. All rights reserved. RMAN> echo set on RMAN> connect target / connected to target database: CDB1 (DBID=914521258) RMAN> delete noprompt backup; using channel ORA_DISK_1 using channel ORA_DISK_2 using channel ORA_DISK_3 using channel ORA_DISK_4 specification does not match any backup in the repository RMAN> list backup; specification does not match any backup in the repository
I have only one PDB here:
RMAN> report schema; Report of database schema for database with db_unique_name CDB1A List of Permanent Datafiles =========================== File Size(MB) Tablespace RB segs Datafile Name ---- -------- -------------------- ------- ------------------------ 1 820 SYSTEM YES /u01/oradata/CDB1A/system01.dbf 3 630 SYSAUX NO /u01/oradata/CDB1A/sysaux01.dbf 4 70 UNDOTBS1 YES /u01/oradata/CDB1A/undotbs01.dbf 5 250 PDB$SEED:SYSTEM NO /u01/oradata/CDB1A/pdbseed/system01.dbf 6 330 PDB$SEED:SYSAUX NO /u01/oradata/CDB1A/pdbseed/sysaux01.dbf 7 5 USERS NO /u01/oradata/CDB1A/users01.dbf 8 100 PDB$SEED:UNDOTBS1 NO /u01/oradata/CDB1A/pdbseed/undotbs01.dbf 103 250 PDB1:SYSTEM YES /u01/oradata/CDB1A/PDB1/system01.dbf 104 350 PDB1:SYSAUX NO /u01/oradata/CDB1A/PDB1/sysaux01.dbf 105 100 PDB1:UNDOTBS1 YES /u01/oradata/CDB1A/PDB1/undotbs01.dbf List of Temporary Files ======================= File Size(MB) Tablespace Maxsize(MB) Tempfile Name ---- -------- -------------------- ----------- -------------------- 1 131 TEMP 32767 /u01/oradata/CDB1A/temp01.dbf 2 64 PDB$SEED:TEMP 32767 /u01/oradata/CDB1A/pdbseed/temp012017-04-08_22-24-09-441-PM.dbf 4 64 PDB1:TEMP 32767 /u01/oradata/CDB1A/PDB1/temp012017-04-08_22-24-09-441-PM.dbf
all datafiles need backup:
RMAN> report need backup; RMAN retention policy will be applied to the command RMAN retention policy is set to redundancy 1 Report of files with less than 1 redundant backups File #bkps Name ---- ----- ----------------------------------------------------- 1 0 /u01/oradata/CDB1A/system01.dbf 3 0 /u01/oradata/CDB1A/sysaux01.dbf 4 0 /u01/oradata/CDB1A/undotbs01.dbf 5 0 /u01/oradata/CDB1A/pdbseed/system01.dbf 6 0 /u01/oradata/CDB1A/pdbseed/sysaux01.dbf 7 0 /u01/oradata/CDB1A/users01.dbf 8 0 /u01/oradata/CDB1A/pdbseed/undotbs01.dbf 103 0 /u01/oradata/CDB1A/PDB1/system01.dbf 104 0 /u01/oradata/CDB1A/PDB1/sysaux01.dbf 105 0 /u01/oradata/CDB1A/PDB1/undotbs01.dbf
I backup only the pluggable database PDB1
RMAN> backup pluggable database PDB1; Starting backup at 30-APR-17 using channel ORA_DISK_1 using channel ORA_DISK_2 using channel ORA_DISK_3 using channel ORA_DISK_4 channel ORA_DISK_1: starting full datafile backup set channel ORA_DISK_1: specifying datafile(s) in backup set input datafile file number=00104 name=/u01/oradata/CDB1A/PDB1/sysaux01.dbf channel ORA_DISK_1: starting piece 1 at 30-APR-17 channel ORA_DISK_2: starting full datafile backup set channel ORA_DISK_2: specifying datafile(s) in backup set input datafile file number=00103 name=/u01/oradata/CDB1A/PDB1/system01.dbf channel ORA_DISK_2: starting piece 1 at 30-APR-17 channel ORA_DISK_3: starting full datafile backup set channel ORA_DISK_3: specifying datafile(s) in backup set input datafile file number=00105 name=/u01/oradata/CDB1A/PDB1/undotbs01.dbf channel ORA_DISK_3: starting piece 1 at 30-APR-17 channel ORA_DISK_1: finished piece 1 at 30-APR-17 piece handle=/u01/fast_recovery_area/CDB1A/4E68DF57035A648FE053684EA8C01C78/backupset/2017_04_30/o1_mf_nnndf_TAG20170430T221146_djdk827s_.bkp tag=TAG20170430T221146 comment=NONE channel ORA_DISK_1: backup set complete, elapsed time: 00:00:03 channel ORA_DISK_3: finished piece 1 at 30-APR-17 piece handle=/u01/fast_recovery_area/CDB1A/4E68DF57035A648FE053684EA8C01C78/backupset/2017_04_30/o1_mf_nnndf_TAG20170430T221146_djdk83go_.bkp tag=TAG20170430T221146 comment=NONE channel ORA_DISK_3: backup set complete, elapsed time: 00:00:03 channel ORA_DISK_2: finished piece 1 at 30-APR-17 piece handle=/u01/fast_recovery_area/CDB1A/4E68DF57035A648FE053684EA8C01C78/backupset/2017_04_30/o1_mf_nnndf_TAG20170430T221146_djdk830z_.bkp tag=TAG20170430T221146 comment=NONE channel ORA_DISK_2: backup set complete, elapsed time: 00:00:03 Finished backup at 30-APR-17 Starting Control File and SPFILE Autobackup at 30-APR-17 piece handle=/u01/fast_recovery_area/CDB1A/autobackup/2017_04_30/o1_mf_s_942703909_djdk85m1_.bkp comment=NONE Finished Control File and SPFILE Autobackup at 30-APR-17
Here is the proof that only PDB1 has a backup, the CDB$ROOT has no backup:
RMAN> report need backup; RMAN retention policy will be applied to the command RMAN retention policy is set to redundancy 1 Report of files with less than 1 redundant backups File #bkps Name ---- ----- ----------------------------------------------------- 1 0 /u01/oradata/CDB1A/system01.dbf 3 0 /u01/oradata/CDB1A/sysaux01.dbf 4 0 /u01/oradata/CDB1A/undotbs01.dbf 5 0 /u01/oradata/CDB1A/pdbseed/system01.dbf 6 0 /u01/oradata/CDB1A/pdbseed/sysaux01.dbf 7 0 /u01/oradata/CDB1A/users01.dbf 8 0 /u01/oradata/CDB1A/pdbseed/undotbs01.dbf
I will do PDB Point In Time Recovery, using a restore point
RMAN> create restore point RP; Statement processed RMAN> alter pluggable database PDB1 close; Statement processedHere is the restore
RMAN> restore pluggable database PDB1 until restore point RP; Starting restore at 30-APR-17 allocated channel: ORA_DISK_1 channel ORA_DISK_1: SID=15 device type=DISK allocated channel: ORA_DISK_2 channel ORA_DISK_2: SID=149 device type=DISK allocated channel: ORA_DISK_3 channel ORA_DISK_3: SID=268 device type=DISK allocated channel: ORA_DISK_4 channel ORA_DISK_4: SID=398 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 00104 to /u01/oradata/CDB1A/PDB1/sysaux01.dbf channel ORA_DISK_1: reading from backup piece /u01/fast_recovery_area/CDB1A/4E68DF57035A648FE053684EA8C01C78/backupset/2017_04_30/o1_mf_nnndf_TAG20170430T221146_djdk827s_.bkp channel ORA_DISK_2: starting datafile backup set restore channel ORA_DISK_2: specifying datafile(s) to restore from backup set channel ORA_DISK_2: restoring datafile 00105 to /u01/oradata/CDB1A/PDB1/undotbs01.dbf channel ORA_DISK_2: reading from backup piece /u01/fast_recovery_area/CDB1A/4E68DF57035A648FE053684EA8C01C78/backupset/2017_04_30/o1_mf_nnndf_TAG20170430T221146_djdk83go_.bkp channel ORA_DISK_3: starting datafile backup set restore channel ORA_DISK_3: specifying datafile(s) to restore from backup set channel ORA_DISK_3: restoring datafile 00103 to /u01/oradata/CDB1A/PDB1/system01.dbf channel ORA_DISK_3: reading from backup piece /u01/fast_recovery_area/CDB1A/4E68DF57035A648FE053684EA8C01C78/backupset/2017_04_30/o1_mf_nnndf_TAG20170430T221146_djdk830z_.bkp channel ORA_DISK_2: piece handle=/u01/fast_recovery_area/CDB1A/4E68DF57035A648FE053684EA8C01C78/backupset/2017_04_30/o1_mf_nnndf_TAG20170430T221146_djdk83go_.bkp tag=TAG20170430T221146 channel ORA_DISK_2: restored backup piece 1 channel ORA_DISK_2: restore complete, elapsed time: 00:00:03 channel ORA_DISK_3: piece handle=/u01/fast_recovery_area/CDB1A/4E68DF57035A648FE053684EA8C01C78/backupset/2017_04_30/o1_mf_nnndf_TAG20170430T221146_djdk830z_.bkp tag=TAG20170430T221146 channel ORA_DISK_3: restored backup piece 1 channel ORA_DISK_3: restore complete, elapsed time: 00:00:03 channel ORA_DISK_1: piece handle=/u01/fast_recovery_area/CDB1A/4E68DF57035A648FE053684EA8C01C78/backupset/2017_04_30/o1_mf_nnndf_TAG20170430T221146_djdk827s_.bkp tag=TAG20170430T221146 channel ORA_DISK_1: restored backup piece 1 channel ORA_DISK_1: restore complete, elapsed time: 00:00:07 Finished restore at 30-APR-17and the recover
RMAN> recover pluggable database PDB1 until restore point RP; Starting recover at 30-APR-17 using channel ORA_DISK_1 using channel ORA_DISK_2 using channel ORA_DISK_3 using channel ORA_DISK_4 starting media recovery media recovery complete, elapsed time: 00:00:00 Finished recover at 30-APR-17Fimnally, I open resetlogs
RMAN> alter pluggable database PDB1 open resetlogs; Statement processed
Thanks to LOCAL UNDO there is no need to restore the CDB$ROOT into an auxiliary instance, as it was the case for PDBPITR in 12.1 and then we can do PDBPITR without a backup of the root.
In theory, and as demonstrated above, including CDB$ROOT into a partial PDB backup is not mandatory in 12cR2 in local undo mode. However, keep in mind that this is for academic purpose only, not for real-life production. For short-term point in time, you will not use backups but flashback. For long-term restore, then you may have different reasons to restore the PDB elsewhere with its CDB$ROOT at the same point in time: some common objects (users, roles, directories, etc) may have changed. And anyway, your backup strategy should be at CDB level.
Have you done any tests performing a PITR on a PDB and what happens with any existing incremental backups ? I did some testing to simulate what happens during a normal weekly backup cycle with a level 0 backup; level 1 backup; create restore point ‘test’ level 1 backup; Restore pdb to restore point ‘TEST”; recovery pdb to restore point ‘TEST';
As you pointed out, it no longer needs an auxiliary database to restore/recovery with local undo… BUT it also won’t use the incremental backup.. It restores the datafiles from the Level 0 backup and will only use archive logs to perform recovery. The incremental backups are ignored. I’m curious if you’ve tried this, and know the reasoning for it.