OCP 12C – Backup, Recovery and Flashback for a CDB/PDB

Cyrille Modiano

OCP Oracle DBA in Montreal at Desjardins

Latest posts by Cyrille Modiano (see all)

Backup a CDB/PDB

  • To make a database backup you need the SYSBACKUP or SYSDBA privilege.
  • You can backup the CDB and all the PDBs independantly, all together, or by specifying a list.
  • You can backup a PDB by connecting directly to it and use:
    • RMAN> BACKUP DATABASE:
  • You can backup a PDB by connecting to the CDB and use:
    • RMAN> BACKUP PLUGGABLE DATABASE MY_PDB;
  • To backup only the root (CDB$ROOT) connect to the CDB and use:
    • RMAN> BACKUP DATABASE ROOT;
  • You can backup everything by connecting to the CDB and use:
    • RMAN> BACKUP DATABASE;
  • You can backup only some PDBs by using:
    • RMAN > BACKUP PLUGGABLE DATABASE PDB1, PDB2, PDB3;

Backup tablespaces and datafiles in CDBs/PDBs

  • You can backup tablespaces from several PDBs at the same time when connected to the root using:
    • RMAN> BACKUP TABLESPACE PDB1:USERS, PDB2:TOOLS, PDB3:SYSTEM;
  • You can also backup tablespaces using the standard command when you connect directly to the PDB:
    • RMAN> BACKUP TABLESPACE SYSTEM;
  • To backup datafiles for a PDB you can :
    • Connect to the root and use : BACKUP DATAFILE 12,13,14;
    • Connect to the PDB and use : BACKUP DATAFILE 12,13,14;

Restore and recover a CDB/PDB

  • To perform a recover of the whole CDB use:
    • RMAN> RESTORE DATABASE;
    • RMAN> RECOVER DATABASE;
  • To recover only the root, place the CDB in mount state and use:
    • RMAN> RESTORE DATABASE ROOT;
    • RMAN> RECOVER DATABASE ROOT;
  • To prevent metadata inconsistenties ,Oracle recommends to restore the PDBs with the root, to restore the PDBs use the following command:
    • RMAN> RESTORE PLUGGABLE DATABASE PDB1, PDB2, PDB3;
    • RMAN> RECOVER PLUGGABLE DATABASE PDB1, PDB2, PDB3;
  • To restore a specific PDB follow these steps:
    • RMAN> ALTER PLUGGABLE DATABASE PDB1 CLOSE;
    • RMAN> RESTORE PLUGGABLE DATABASE PDB1;
    • RMAN> RECOVER PLUGGABLE DATABASE PDB1;
    • RMAN> ALTER PLUGGABLE DATABASE PDB1 OPEN;

Restore and recover a CDB/PDB tablespace or datafile

  • To restore a tablespace of a PDB database, connect to the root and use:
    • RMAN> RESTORE TABLESPACE PDB1:USERS;
    • RMAN> RECOVER TABLESPACE PDB1:USERS;
  • To restore a PDB datafile, connect to the root and use:
    • RMAN> RESTORE DATAFILE 12;
    • RMAN> RECOVER DATAFILE 12;
  • The previous operations can also be done by connecting directly to the PDB.
  • The procedure to make a PITR of a PDB is :

  • The procedure to make a PITR of a PDB tablespace is:

Performing flashback for a CDB

  • The flashback operation for a CDB is the same as for a standard database
  • YOU CAN’T flashback a CDB to a point in time earlier than the time when you made a PDB PITR.
  • YOU CAN’T flashback a PDB.

8 thoughts on “OCP 12C – Backup, Recovery and Flashback for a CDB/PDB

    1. Hi Preethi,

      Thank you for reading my blog, I’m glad it helps you.
      To answer your question, yes you can backup the PDB$SEED using :

      RMAN> backup pluggable database "PDB$SEED";

      The PDB$SEED is also backed-up when you backup the whole CDB using the BACKUP DATABASE command.

      Cyrille

      1. Thanks Cyrille! Are you aware of any way to get the info of the entire pdbseed in an xml file?

  1. Cyrille ,

    Thanks for the info .This is very helpful .

    Please help me with the following Questions
    1) How to restore and recover CDB and one PDB on a different Server using root and PDB backup
    2) Can we restore PDB using backup to a different Container ?

    Thanks for your time,

    Regards,
    Ramesh

    1. Hi Ramesh,

      Thank you for reading my blog.

      How to restore and recover CDB and one PDB on a different Server using root and PDB backup ?

      I don’t think there is a direct way to do this, what I would do is duplicate the whole CDB.
      The procedure is the same as duplicating a standard database.
      Then you drop the pluggable database you don’t need.

      Can we restore PDB using backup to a different Container ?

      This is a standard duplication, you have to go to the host where you want to duplicate the database.
      You connect with RMAN to the CDB database where the PDB you want to duplicate/restore is located (let’s say CDB1).
      You connect as auxiliary to the CDB where the database will be duplicated/restored (let’s say CDB2)
      You set the time using the SET UNTIL TIME command
      You run a : duplicate target database to CDB2 pluggable database pdb1;

      The will restore the the pluggable database PDB1 to the new CDB at the time specified.
      Of course the backup files needed to restore must be available on the destination host.

      Cyrille

  2. hello,
    can anybody help to find in the oracle docs following syntax for PDB backup from root:
    BACKUP TABLESPACE ‘PDB_TEST1′:’USER_TBS’;

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.