Restore and Recovery Database in Oracle Container

To do an Oracle Restore and Recover database in RMAN, we need to understand that there are two types of situations. We can recover with Full Backup or partial called Point Time.

Restore Recover Backup Full: It is used to restore the database completely in case of major disasters.

Restore Backup Point Time: It is used to recover in a specific time line or before any action that came to harm the database, whether manual or physical.


Let's understand what each command does:


Restore: This command in turn has to bring the files back to their original state until the moment of Backup, with it it is possible to recover the files from (DATAFILES, TABLESPACES, CONTROFILES, ARCHIVED REDO LOG, PARAMETER FILES);


Recover: This command will perform a complete read and recover a database up to the most recent moment, without losing any confirmed transactions.


Container Database (CDB) Complete Recovery


Prerequisites


To start a Database Restore task, the Backups must be complete without fail. The database must be stopped and mounted in case of Complete Restore.


Restore CDB


Performing a restore on a CDB is very similar to a Database that does not have a CDB, the difference being that, when recovering an entire CDB it has all the PDBs and the root container. Likewise, a point time recovery of the entire CDB will bring all PDBs back to the same point in time.

Connect to RMAN using OS authentication execute the script .


rman target /

RUN {
  SHUTDOWN ABORT; 
  STARTUP MOUNT;
  RESTORE DATABASE;
  RECOVER DATABASE;
  ALTER DATABASE OPEN;
}

Pluggable Database (PDB) Complete Recovery


With the database in container format you can restore and recover the PDBs as follows, separately one by one or using the figure (' , ') inform which PDBs will be recovered according to the script below:


rman target 

RUN { 
  ALTER PLUGGABLE DATABASE PDB1, PDB2, PDB3 CLOSE; 
  RESTORE PLUGGABLE DATABASE PDB1, PDB2, PDB3; 
  RECOVER PLUGGABLE DATABASE PDB1, PDB2, PDB3; 
  ALTER PLUGGABLE DATABASE PDB1, PDB2, PDB3 OPEN; 
}

Recovery Datafiles


In the same way in a non-CDB environment to retrieve any Datafiles, it is also possible in a CDB, this process can be done in the following ways while connected to the container or directly to the PDB.


rman target /
# Or
rman target=SYS@ORADES_PDB01

RUN {
  ALTER DATABASE DATAFILE 7 OFFLINE;
  RESTORE DATAFILE 7;
  RECOVER DATAFILE 7;
  ALTER DATABASE DATAFILE 7 ONLINE;
}

Database Point-In-Time Recovery


The point-in-time recovery (DBPITR) of the Container database allows the DBA to recover data at a specific point in time.



The requirements for database point-in-time recovery are as follows:

  • Your database must be running in ARCHIVELOG mode.

  • You must have backups of all Datafiles from before the target SCN for DBPITR and archived redo logs for the period between the SCN of the backups and the target SCN.

Note:

The main detail is that when applying the point-in-time recovery technique on a CDB, all PDBs underwent Restore Recovery at once.


rman target /

RUN {
  SHUTDOWN ABORT; 
  STARTUP MOUNT;
  SET UNTIL TIME "TO_DATE('19/10/2020 15:54:16','DD/MM/YYYY 
  HH24:MI:SS')";
  RESTORE DATABASE;
  RECOVER DATABASE;
  ALTER DATABASE OPEN RESETLOGS;
}


Pluggable Database (PDB) Point In Time Recovery


It can also be to use Point In Time Recovery for PDBs, just close the PDB to be restored and recovered and inform in what point of time you need and RESETLOGS will just create a new incarnation to the PDB. The representation of the PDB in this example in the script is named 'ORADES_PDB01'


RUN {
  ALTER PLUGGABLE DATABASE ORADES_PDB01 CLOSE;
  SET UNTIL TIME "TO_DATE('19/10/2020 16:20:10','DD/MM/YYYY 
  HH24:MI:SS')";
  RESTORE PLUGGABLE DATABASE ORADES_PDB01;
  RECOVER PLUGGABLE DATABASE ORADES_PDB01;
  ALTER PLUGGABLE DATABASE ORADES_PDB01 OPEN RESETLOGS;
}

Thus we concluded another understanding with Oracle Container Database. Restore and Recovery can determine the Database Administrator's success in having a solid Backup Restore strategy.