RMAN (Recovery Manager) is the backup and recovery solution of Oracle database. Oracle Corporation recommends RMAN as the preferred method of backup and recovery. The best part about RMAN is that it detects block corruption while performing backup. You can access RMAN through command line or Oracle Enterprise Manager. Since RMAN is the feature of Oracle so no separate installation is required. RMAN backup provides some advanced features like parallelization of backup/restore, keep history of all backup etc. You can backup following files through RMAN:
- Archive redo log file
- Datafiles, controlfiles and SPFILES.
Types of backup in RMAN
- Full backup: Full backup is used to backup the whole database block by block.
- Incremental backup: It can be of two types, either a 0 level backup or 1 level backup.
- Level 1 backup: It backup only those blocks that have been changed since the last parent backup. Parent backup can be of 0 level or 1 level.
- Level 0 backup: It is same as full backup. The only difference is that it does not backup empty blocks.
- Consistent backup: A consistent backup is taken when the database is shutdown using SHUTDOWN command.
- Inconsistent backup: An inconsistent backup is taken when the database is open or failed after crash.
- Open backup: It is taken when the database is in online mode.
- Closed backup: It is taken when the database is in offline mode.
How to perform backup with RMAN?
To backup whole database: Use below command to backup the whole database:
RMAN> BACKUP DATABASE;
RMAN new features in Oracle 11g
- Data Recovery Advisor: Data Recovery Advisor automatically detects corruption and data failures. It repairs block corruption, data dictionary corruptions and many more.
- Cloning of database: You can easily clone your database without requiring existing backups.
- Improvement in backup compression: In Oracle 11g, RMAN backup compression is done using ZLIB algorithm which is much faster than BZIP2 algorithm that is used in Oracle 10g.
- Check physical corruption: A new command is introduced in Oracle 11g to check database for physical corruption. The command is VALIDATE DATABASE.
Why use RMAN?
RMAN is the preferred method of backup and recovery. Since RMAN is supported by Oracle so while using it if you find any issue you can always rely on Oracle for support. Here are the advantages of using RMAN:
- RMAN automatically detects block corruption while performing backup. In RAMN you can recover only few corrupted block unlike traditional backups where you have to backup entire data file.
- RMAN also performs incremental backup. In incremental backup only those blocks are backed up that are changed since last backup. So it reduces recovery time because now you don't have to backup the entire database.
- It provides automatic backup of controlfile and spfile.
- You can also perform encrypted backup using RMAN which is not possible in traditional backups.
- Using RMAN you can easily check any backup that whether it is recoverable or not.
- In RMAN backup compression there is a feature by which you can skip unused blocks.
- RMAN can work fairly well with third party tools.
- RMAN backup is much faster than other traditional backups.
- RMAN has an highly advanced feature named Data Recovery Advisor that automatically detects and repair block corruption.
- RMAN automatically deletes expired or unnecessary backup of data file from disk.
- You can perform backup in online mode without putting the tablespace in hot backup mode.
RMAN backup best practices
If you are using RMAN as your backup strategy then follow best practices for performing backup. However RMAN is intelligent enough to automatically detect which files need to be restored and backup. Consider following factors while performing backup:
- Choose the backup option depending upon your business requirement: RMAN provide many type of backups. Choose the one that can provide fastest recovery for your business.
- Check validity of backup: Perform a media check on your backup storage. A disk to disk backup is considered as most reliable and fastest backup.
- Check the speed of backup: Check how long does it take to perform backup.
RMAN backup optimization
There are two commands in RMAN backup optimization. Here they are:
RMAN> configure backup optimization on;
RMAN> configure backup optimization off;
When backup optimization is On then BACKUP command will skip the backup of that file which has already been backed up to a specific device. RMAN check for identical files for example in case of datafile, it will check for checkpoint SCN, DBID, creation SCN to see if they are already backed up. By default backup optimization is off. Consider some of the key features of configure backup optimization On command:
- If you want to backup flash recovery area using RMAN then you need to set the configure backup optimization command to on.
- If you set backup optimization to On then RMAN will skip the backup of identical files.
Some of the useful commands of RMAN are:
RMAN> show all;
To show all the RMAN parameters of the database.
RMAN> backup database;
To perform backup of database.
RMAN> delete expire backup;
To remove any archive log.
RMAN> report obsolete;
To delete obsolete backup.
RMAN> alter database;
To mount a database.
To delete the backup copy of database.
To exit the RMAN executable.
To restore files from backup to an new location.
To create a duplicate database of target backup for testing purpose.
To show the current configuration settings.