Container Database (CDB) Full Recovery
Restoring a CDB is similar to restoring a non-CDB database, but remember restoring a whole CDB will restore not only the root container, but all the PDBs also.
Same in a Point In Time Recovery (PITR) of the whole CDB will bring all PDBs back to the same point in time.
Connect to RMAN using OS authentication and restore the whole CDB using the following restore script. This means you are connecting to the root container with “AS SYSDBA” privilege.
[oracle@ram admin]$ rman target / Recovery Manager: Release 12.2.0.1.0 - Production on Tue Oct 9 19:45:41 2018 Copyright (c) 1982, 2017, Oracle and/or its affiliates. All rights reserved. connected to target database: DBWR (DBID=1322876759) RMAN> RUN { SHUTDOWN IMMEDIATE; STARTUP MOUNT; RESTORE DATABASE; RECOVER DATABASE; ALTER DATABASE OPEN; } using target database control file instead of recovery catalog database closed database dismounted Oracle instance shut down connected to target database (not started) Oracle instance started database mounted Total System Global Area 2516582400 bytes Fixed Size 8795904 bytes Variable Size 671090944 bytes Database Buffers 1828716544 bytes Redo Buffers 7979008 bytes Starting restore at 09-OCT-18 allocated channel: ORA_DISK_1 channel ORA_DISK_1: SID=35 device type=DISK skipping datafile 5; already restored to file /u01/app/oracle/oradata/DBWR/datafile/o1_mf_system_fvgr1m0c_.dbf skipping datafile 6; already restored to file /u01/app/oracle/oradata/DBWR/datafile/o1_mf_sysaux_fvgr1m08_.dbf skipping datafile 8; already restored to file /u01/app/oracle/oradata/DBWR/datafile/o1_mf_undotbs1_fvgr1m0f_.dbf skipping datafile 13; already restored to file /u01/app/oracle/oradata/DBWR/777D95E41A572D82E053DD971D40E224/datafile/o1_mf_system_fvgzcl9q_.dbf skipping datafile 14; already restored to file /u01/app/oracle/oradata/DBWR/777D95E41A572D82E053DD971D40E224/datafile/o1_mf_sysaux_fvgzclb4_.dbf skipping datafile 15; already restored to file /u01/app/oracle/oradata/DBWR/777D95E41A572D82E053DD971D40E224/datafile/o1_mf_undotbs1_fvgzclb5_.dbf skipping datafile 16; already restored to file /u01/app/oracle/oradata/DBWR/777D95E41A572D82E053DD971D40E224/datafile/o1_mf_users_fvgzd8cs_.dbf skipping datafile 21; already restored to file /u01/app/oracle/oradata/DBWR/datafile/o1_mf_system_fvhgn44z_.dbf skipping datafile 22; already restored to file /u01/app/oracle/oradata/DBWR/datafile/o1_mf_sysaux_fvhgn44v_.dbf skipping datafile 24; already restored to file /u01/app/oracle/oradata/DBWR/datafile/o1_mf_users_fvhgn454_.dbf skipping datafile 23; already restored to file /u01/app/oracle/oradata/DBWR/datafile/o1_mf_undotbs1_fvhgn452_.dbf 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 00004 to /u01/app/oracle/oradata/DBWR/datafile/o1_mf_undotbs1_fvgqyx60_.dbf channel ORA_DISK_1: reading from backup piece /u01/app/oracle/fast_recovery_area/dbwr/DBWR/backupset/2018_10_09/o1_mf_nnndf_TAG20181009T032653_fvqno5rt_.bkp channel ORA_DISK_1: piece handle=/u01/app/oracle/fast_recovery_area/dbwr/DBWR/backupset/2018_10_09/o1_mf_nnndf_TAG20181009T032653_fvqno5rt_.bkp tag=TAG20181009T032653 channel ORA_DISK_1: restored backup piece 1 channel ORA_DISK_1: restore complete, elapsed time: 00:00:03 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 /u01/app/oracle/oradata/DBWR/datafile/o1_mf_system_fvgqv1n6_.dbf channel ORA_DISK_1: restoring datafile 00003 to /u01/app/oracle/oradata/DBWR/datafile/o1_mf_sysaux_fvgqxhq9_.dbf channel ORA_DISK_1: reading from backup piece /u01/app/oracle/fast_recovery_area/dbwr/DBWR/backupset/2018_10_09/o1_mf_nnndf_TAG20181009T182505_fvs999th_.bkp channel ORA_DISK_1: piece handle=/u01/app/oracle/fast_recovery_area/dbwr/DBWR/backupset/2018_10_09/o1_mf_nnndf_TAG20181009T182505_fvs999th_.bkp tag=TAG20181009T182505 channel ORA_DISK_1: restored backup piece 1 channel ORA_DISK_1: restore complete, elapsed time: 00:00:35 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 00007 to /u01/app/oracle/oradata/DBWR/datafile/o1_mf_users_fvgqyy96_.dbf channel ORA_DISK_1: reading from backup piece /u01/app/oracle/fast_recovery_area/dbwr/DBWR/backupset/2018_10_09/o1_mf_nnndf_TAG20181009T183709_fvsb0to6_.bkp channel ORA_DISK_1: piece handle=/u01/app/oracle/fast_recovery_area/dbwr/DBWR/backupset/2018_10_09/o1_mf_nnndf_TAG20181009T183709_fvsb0to6_.bkp tag=TAG20181009T183709 channel ORA_DISK_1: restored backup piece 1 channel ORA_DISK_1: restore complete, elapsed time: 00:00:01 Finished restore at 09-OCT-18 Starting recover at 09-OCT-18 using channel ORA_DISK_1 starting media recovery media recovery complete, elapsed time: 00:00:02 Finished recover at 09-OCT-18 Statement processed
Root Container Full Recovery
Instead of recovering the whole CDB, including all PDBs, the root container can be recovered in isolation.
Connect to RMAN using OS authentication and restore the root container using the following restore script.
It means you are connecting to the root container with “AS SYSDBA” privilege.
[oracle@ram admin]$ rman target / Recovery Manager: Release 12.2.0.1.0 - Production on Tue Oct 9 20:09:10 2018 Copyright (c) 1982, 2017, Oracle and/or its affiliates. All rights reserved. connected to target database: DBWR (DBID=1322876759) RMAN> RUN { SHUTDOWN IMMEDIATE; STARTUP MOUNT; RESTORE DATABASE ROOT; RECOVER DATABASE ROOT; ALTER DATABASE OPEN; } using target database control file instead of recovery catalog database closed database dismounted Oracle instance shut down connected to target database (not started) Oracle instance started database mounted Total System Global Area 2516582400 bytes Fixed Size 8795904 bytes Variable Size 671090944 bytes Database Buffers 1828716544 bytes Redo Buffers 7979008 bytes Starting restore at 09-OCT-18 allocated channel: ORA_DISK_1 channel ORA_DISK_1: SID=8 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 00004 to /u01/app/oracle/oradata/DBWR/datafile/o1_mf_undotbs1_fvgqyx60_.dbf channel ORA_DISK_1: reading from backup piece /u01/app/oracle/fast_recovery_area/dbwr/DBWR/backupset/2018_10_09/o1_mf_nnndf_TAG20181009T032653_fvqno5rt_.bkp channel ORA_DISK_1: piece handle=/u01/app/oracle/fast_recovery_area/dbwr/DBWR/backupset/2018_10_09/o1_mf_nnndf_TAG20181009T032653_fvqno5rt_.bkp tag=TAG20181009T032653 channel ORA_DISK_1: restored backup piece 1 channel ORA_DISK_1: restore complete, elapsed time: 00:00:03 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 /u01/app/oracle/oradata/DBWR/datafile/o1_mf_system_fvgqv1n6_.dbf channel ORA_DISK_1: restoring datafile 00003 to /u01/app/oracle/oradata/DBWR/datafile/o1_mf_sysaux_fvgqxhq9_.dbf channel ORA_DISK_1: reading from backup piece /u01/app/oracle/fast_recovery_area/dbwr/DBWR/backupset/2018_10_09/o1_mf_nnndf_TAG20181009T182505_fvs999th_.bkp channel ORA_DISK_1: piece handle=/u01/app/oracle/fast_recovery_area/dbwr/DBWR/backupset/2018_10_09/o1_mf_nnndf_TAG20181009T182505_fvs999th_.bkp tag=TAG20181009T182505 channel ORA_DISK_1: restored backup piece 1 channel ORA_DISK_1: restore complete, elapsed time: 00:00:27 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 00007 to /u01/app/oracle/oradata/DBWR/datafile/o1_mf_users_fvgqyy96_.dbf channel ORA_DISK_1: reading from backup piece /u01/app/oracle/fast_recovery_area/dbwr/DBWR/backupset/2018_10_09/o1_mf_nnndf_TAG20181009T183709_fvsb0to6_.bkp channel ORA_DISK_1: piece handle=/u01/app/oracle/fast_recovery_area/dbwr/DBWR/backupset/2018_10_09/o1_mf_nnndf_TAG20181009T183709_fvsb0to6_.bkp tag=TAG20181009T183709 channel ORA_DISK_1: restored backup piece 1 channel ORA_DISK_1: restore complete, elapsed time: 00:00:01 Finished restore at 09-OCT-18 Starting recover at 09-OCT-18 using channel ORA_DISK_1 starting media recovery media recovery complete, elapsed time: 00:00:02 Finished recover at 09-OCT-18 Statement processed
It is not a good to restore and recover just the root container without doing the same for the PDBs.
If there any difference in metadata between the two could create problem.so better avoid this.
Pluggable Database (PDB) Recovery Scenario
There are two ways to restore and recover PDBs.
1.Connect to root containers, you can restore and recover one or more PDBs.
2.Connect directly to a PDB, you can restore and recover the current PDB using a local user with the SYSDBA privilege.
[oracle@ram ~]$ rman target / Recovery Manager: Release 12.2.0.1.0 - Production on Tue Oct 9 20:23:47 2018 Copyright (c) 1982, 2017, Oracle and/or its affiliates. All rights reserved. connected to target database: DBWR (DBID=1322876759) RMAN> RUN { ALTER PLUGGABLE DATABASE pdb5, pdb6 CLOSE; RESTORE PLUGGABLE DATABASE pdb5, pdb6; RECOVER PLUGGABLE DATABASE pdb5, pdb6; ALTER PLUGGABLE DATABASE pdb5, pdb6 OPEN; }2> 3> 4> 5> 6> using target database control file instead of recovery catalog Statement processed Starting restore at 09-OCT-18 allocated channel: ORA_DISK_1 channel ORA_DISK_1: SID=33 device type=DISK skipping datafile 13; already restored to file /u01/app/oracle/oradata/DBWR/777D95E41A572D82E053DD971D40E224/datafile/o1_mf_system_fvgzcl9q_.dbf skipping datafile 14; already restored to file /u01/app/oracle/oradata/DBWR/777D95E41A572D82E053DD971D40E224/datafile/o1_mf_sysaux_fvgzclb4_.dbf skipping datafile 15; already restored to file /u01/app/oracle/oradata/DBWR/777D95E41A572D82E053DD971D40E224/datafile/o1_mf_undotbs1_fvgzclb5_.dbf skipping datafile 16; already restored to file /u01/app/oracle/oradata/DBWR/777D95E41A572D82E053DD971D40E224/datafile/o1_mf_users_fvgzd8cs_.dbf skipping datafile 21; already restored to file /u01/app/oracle/oradata/DBWR/datafile/o1_mf_system_fvhgn44z_.dbf skipping datafile 22; already restored to file /u01/app/oracle/oradata/DBWR/datafile/o1_mf_sysaux_fvhgn44v_.dbf skipping datafile 24; already restored to file /u01/app/oracle/oradata/DBWR/datafile/o1_mf_users_fvhgn454_.dbf skipping datafile 23; already restored to file /u01/app/oracle/oradata/DBWR/datafile/o1_mf_undotbs1_fvhgn452_.dbf restore not done; all files read only, offline, excluded, or already restored Finished restore at 09-OCT-18 Starting recover at 09-OCT-18 using channel ORA_DISK_1 starting media recovery media recovery complete, elapsed time: 00:00:00 Finished recover at 09-OCT-18 Statement processed
Alternate way,
[oracle@ram ~]$ sqlplus sys@pdb5 as sysdba SQL*Plus: Release 12.2.0.1.0 Production on Tue Oct 9 20:27:27 2018 Copyright (c) 1982, 2016, Oracle. All rights reserved. Enter password: Connected to: Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production SQL> CREATE USER prasath IDENTIFIED BY prasath; User created. SQL> GRANT CREATE SESSION, PDB_DBA, SYSDBA TO prasath; Grant succeeded. SQL> exit Disconnected from Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production [oracle@ram ~]$ rman target=prasath@pdb5 Recovery Manager: Release 12.2.0.1.0 - Production on Tue Oct 9 20:28:54 2018 Copyright (c) 1982, 2017, Oracle and/or its affiliates. All rights reserved. target database Password: connected to target database: DBWR:PDB5 (DBID=2599175923) RMAN> SHUTDOWN IMMEDIATE; RESTORE DATABASE; RECOVER DATABASE; STARTUP; using target database control file instead of recovery catalog database closed RMAN> Starting restore at 09-OCT-18 allocated channel: ORA_DISK_1 channel ORA_DISK_1: SID=8 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 00023 to /u01/app/oracle/oradata/DBWR/datafile/o1_mf_undotbs1_fvhgn452_.dbf channel ORA_DISK_1: reading from backup piece /u01/app/oracle/fast_recovery_area/dbwr/DBWR/77813D4B379738F5E0536501A8C05864/backupset/2018_10_09/o1_mf_nnndf_TAG20181009T032653_fvqnpr4p_.bkp channel ORA_DISK_1: piece handle=/u01/app/oracle/fast_recovery_area/dbwr/DBWR/77813D4B379738F5E0536501A8C05864/backupset/2018_10_09/o1_mf_nnndf_TAG20181009T032653_fvqnpr4p_.bkp tag=TAG20181009T032653 channel ORA_DISK_1: restored backup piece 1 channel ORA_DISK_1: restore complete, elapsed time: 00:00:07 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 00021 to /u01/app/oracle/oradata/DBWR/datafile/o1_mf_system_fvhgn44z_.dbf channel ORA_DISK_1: restoring datafile 00022 to /u01/app/oracle/oradata/DBWR/datafile/o1_mf_sysaux_fvhgn44v_.dbf channel ORA_DISK_1: restoring datafile 00024 to /u01/app/oracle/oradata/DBWR/datafile/o1_mf_users_fvhgn454_.dbf channel ORA_DISK_1: reading from backup piece /u01/app/oracle/fast_recovery_area/dbwr/DBWR/77813D4B379738F5E0536501A8C05864/backupset/2018_10_09/o1_mf_nnndf_TAG20181009T183030_fvs9mgjy_.bkp channel ORA_DISK_1: piece handle=/u01/app/oracle/fast_recovery_area/dbwr/DBWR/77813D4B379738F5E0536501A8C05864/backupset/2018_10_09/o1_mf_nnndf_TAG20181009T183030_fvs9mgjy_.bkp tag=TAG20181009T183030 channel ORA_DISK_1: restored backup piece 1 channel ORA_DISK_1: restore complete, elapsed time: 00:00:25 Finished restore at 09-OCT-18 RMAN> Starting recover at 09-OCT-18 using channel ORA_DISK_1 starting media recovery media recovery complete, elapsed time: 00:00:00 Finished recover at 09-OCT-18
Tablespace and Datafile Recovery
Restoring a tablespace must be connected to the PDB.
But Datafile restoring can connected to the container or directly to the PDB.
[oracle@ram ~]$ rman target=sys@pdb5 Recovery Manager: Release 12.2.0.1.0 - Production on Tue Oct 9 20:48:06 2018 Copyright (c) 1982, 2017, Oracle and/or its affiliates. All rights reserved. target database Password: connected to target database: DBWR:PDB5 (DBID=2599175923) RMAN> RUN { ALTER TABLESPACE users OFFLINE; RESTORE TABLESPACE users; RECOVER TABLESPACE users; ALTER TABLESPACE users ONLINE; } using target database control file instead of recovery catalog Statement processed Starting restore at 09-OCT-18 allocated channel: ORA_DISK_1 channel ORA_DISK_1: SID=68 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 00024 to /u01/app/oracle/oradata/DBWR/datafile/o1_mf_users_fvhgn454_.dbf channel ORA_DISK_1: reading from backup piece /u01/app/oracle/fast_recovery_area/dbwr/DBWR/77813D4B379738F5E0536501A8C05864/backupset/2018_10_09/o1_mf_nnndf_TAG20181009T183030_fvs9mgjy_.bkp channel ORA_DISK_1: piece handle=/u01/app/oracle/fast_recovery_area/dbwr/DBWR/77813D4B379738F5E0536501A8C05864/backupset/2018_10_09/o1_mf_nnndf_TAG20181009T183030_fvs9mgjy_.bkp tag=TAG20181009T183030 channel ORA_DISK_1: restored backup piece 1 channel ORA_DISK_1: restore complete, elapsed time: 00:00:01 Finished restore at 09-OCT-18 Starting recover at 09-OCT-18 using channel ORA_DISK_1 applied offline range to datafile 00024 offline range RECID=69 STAMP=989095658 starting media recovery media recovery complete, elapsed time: 00:00:00 Finished recover at 09-OCT-18 Statement processed
Datafile Recovery:
[oracle@ram ~]$ rman target=sys@pdb5 Recovery Manager: Release 12.2.0.1.0 - Production on Tue Oct 9 20:51:24 2018 Copyright (c) 1982, 2017, Oracle and/or its affiliates. All rights reserved. target database Password: connected to target database: DBWR:PDB5 (DBID=2599175923) RMAN> RUN { ALTER DATABASE DATAFILE 24 OFFLINE; RESTORE DATAFILE 24; RECOVER DATAFILE 24; ALTER DATABASE DATAFILE 24 ONLINE; } using target database control file instead of recovery catalog Statement processed Starting restore at 09-OCT-18 allocated channel: ORA_DISK_1 channel ORA_DISK_1: SID=53 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 00024 to /u01/app/oracle/oradata/DBWR/datafile/o1_mf_users_fvhgn454_.dbf channel ORA_DISK_1: reading from backup piece /u01/app/oracle/fast_recovery_area/dbwr/DBWR/77813D4B379738F5E0536501A8C05864/backupset/2018_10_09/o1_mf_nnndf_TAG20181009T183030_fvs9mgjy_.bkp channel ORA_DISK_1: piece handle=/u01/app/oracle/fast_recovery_area/dbwr/DBWR/77813D4B379738F5E0536501A8C05864/backupset/2018_10_09/o1_mf_nnndf_TAG20181009T183030_fvs9mgjy_.bkp tag=TAG20181009T183030 channel ORA_DISK_1: restored backup piece 1 channel ORA_DISK_1: restore complete, elapsed time: 00:00:01 Finished restore at 09-OCT-18 Starting recover at 09-OCT-18 using channel ORA_DISK_1 applied offline range to datafile 00024 offline range RECID=69 STAMP=989095658 starting media recovery media recovery complete, elapsed time: 00:00:01 Finished recover at 09-OCT-18 Statement processed.
Catch Me On:- Hariprasath Rajaram
Telegram:https://t.me/joinchat/I_f4DhGF_Zifr9YZvvMkRg
LinkedIn:https://www.linkedin.com/in/hari-prasath-aa65bb19/
Facebook:https://www.facebook.com/HariPrasathdba
FB Group:https://www.facebook.com/groups/894402327369506/
FB Page: https://www.facebook.com/dbahariprasath/?
Twitter: https://twitter.com/hariprasathdba