Changes to RMAN in Oracle 12c have been made to accommodate pluggable databases and new features, such as recovering a table.
Should you use the standard “BACKUP DATABASE PLUS ARCHIVELOG;” command in RMAN, you will be able to back up the container database (CDB) and all pluggable databases (PDB), as well as your archivelogs.
From this backup you will be able to recover and restore any PDB within that CDB.
Notice what gets backed up in the above log info. RMAN is backing up all datafiles for all the CDB and PDB databases, including pdbseed, and is keeping each PDB in separate backup sets.
While maybe not necessary, you may have a need to backup just the container or just a pluggable database.
To do that, use the “ROOT” and “PLUGGABLE DATABASE <PDB names> commands.
You can use these also for RECOVER and RESTORE commands Oracle 12c.
Commands for the container database only:
Commands for the pluggable databases:
You will need to keep in mind what you want to restore/recover before you start when working with pluggable databases.
If you only want one of your pluggable databases restored – but type “RESTORE DATABASE” – you will get ALL your pluggable databases and your container database restored.
Oracle has also put their opinion into the mix.
A note from Oracle on this is found in http://docs.oracle.com/database/121/BRADV/rcmcomre.htm#i1009223
It states: “You might consider recovering only the root if a data corruption or user error occurs that affects only the root. However, Oracle strongly recommends that you recover all PDBs after recovering the root to prevent metadata inconsistencies among the root and the PDBs. In this case, it might be preferable to perform a complete recovery of the whole CDB.”
SQL Interface for RMAN
Another new feature is the greater and easier use of SQL statements through an interface in RMAN. Before 12c, you were very limited in the SQL commands you could use within RMAN, and they had to follow a certain format.
As you can see, you had to put the word SQL at the beginning, then double-quotes around the command and even two single quotes around the datafile name just to run this statement before 12c.
Now, you just type the command as you would in SQL.
And if you don’t remember the datafile name you want to put offline, you can use now use select statements in 12c to find that information.
RECOVER TABLE Option
- One of the major improvements in RMAN for Oracle 12c is the ability to recover a table or partition online.
- Before 12c, you had to either use flashback options (if you had it enabled and working right and could catch it at the right time). Another option was to recover the tablespace to another database, then export the table you want, then import it back into your database.
- With 12c, you can use the RMAN RECOVER TABLE command to bring a table or partition back to the database. You can use it to bring it directly in, in with a new name, or to an export file.
- What this RECOVER TABLE command does is the same thing you would do if recovering to another database and doing the export/import, but it does it with just the RECOVER TABLE command and a point-in-time recovery (either SCN or until time).
- Keep in mind that the AUXILIARY DESTINATION directory will need to be large enough to hold the SYSTEM, SYSAUX, UNDOTBS, and tablespace that contains the table.
- When you run this command, RMAN creates a temporary automatic instance, adds the SYSTEM, SYSAUX, UNDOTBS, and tablespace containing the data of your table.
- Then it exports the table and imports it into your current system (if you choose that option). It can also REMAP the table to a new table_name.
- Once it has done the export, it will shut down the automatic instance and remove the database/datafiles from the AUXILIARY DESTINATION.
The RMAN logs will be long, so we will just show you the basic commands to run these:
As you can see, you can do multiple tables or partitions at once. Just be prepared for the additional space needed in AUXILIARY DESTINATION.
While RMAN has been changed to accommodate pluggable databases, it has also been improved with some new features we discussed. The key to RMAN is to always backup your databases, as often as possible.
We hope this article will help you when working with Oracle 12c and beyond.