Every database in your network environment should be backed up for disaster recovery, and the Oracle Recovery Manager (RMAN) is an optional application with the Oracle database engine to automate backups. Because it’s built by the Oracle team that manages the database engine, it’s the preferred backup method for many administrators.
What Is Oracle Recovery Manager?
Database administrators need to find ways to consistently back up business databases for security and compliance. Missing just one backup schedule could affect business continuity if the database engine fails or if an event corrupts data that must be recovered. The RMAN tool automatically takes a snapshot of the database, its data, and objects that store data (e.g., tables and views).
The RMAN tool takes full or incremental backups, and database administrators can configure it to encrypt backups for security. RMAN supports several backup strategies, and administrators can configure the tool to support any business requirements, compliance concerns, and recovery options.
How Oracle RMAN Works: Backups
The backup process requires a source database that must be backed up and a target location for storing backup files. The RMAN agent runs on a server and stores configurations from administrators to determine when and where backups happen. Also, administrators can set retention periods to keep backups for a given period of time.
After administrators configure RMAN, the backup procedure automatically triggers using the frequency configured in the application. It takes a snapshot of data and stores it in the backup location. The location could be a local drive, a network drive, or an external device. Administrators can also take a snapshot manually on demand at any time.
How Oracle RMAN Works: Recovery
RMAN supports two types of recovery methods: flashbacks and media recovery. Flashback recovery goes back to a specific point in time and restores data. Administrators use this method when users accidentally delete data or a rare event causes corruption of specific data.
To restore entire database files or large amounts of corrupted data, media recovery restores files from the backup location to the production server. The advantage of media recovery is that administrators do not need to stop the database engine and cause downtime on the production environment. It’s often used when files are corrupted or production media fails.
10 Most Common RMAN Backup Commands
RMAN has several command-line statements to configure and execute backups. The following list has the 10 most commonly used commands with examples.
Perform a full database backup
RMAN> BACKUP DATABASE;
You can also backup the database with all logs using the following command:
RMAN> BACKUP DATABASE PLUS ARCHIVELOG;
Perform an incremental backup
RMAN> BACKUP incremental level 0 DATABASE PLUS ARCHIVELOG;
A level 0 backup is the starting point for an incremental backup. Incremental backups take copies of only data that has changed since the previous backup. They save time and space instead of taking a full copy for every backup. In this example, the logs are also backed up, but just like a full backup, it’s an optional part of the command.
Format backup files
Formatting backup files lets administrators create a unique name for every file for quick recognition during the recovery process. Oracle will generate a unique name for each file using the %U placeholder. The following statement determines the directory and file name for every file.
RMAN> BACKUP DATABASE FORMAT “/dbbackup/backup_%U”;
Back up a table only
RMAN> BACKUP TABLESPACE customer to destination ‘/dbbackup/’;
Back up a datafile
Datafiles store data using the Oracle proprietary storage format. The following command backs up these files for recovery in case of device failure.
RMAN> BACKUP DATAFILE ‘/dboracle/customer.dbf’ to destination ‘/dbbackup/’;
Restore database from a full backup
Backups are automatically stored in the /backup/rman directory. To restore a database from a full backup, use the following command:
RMAN> RESTORE DATABASE;
Restore a specific table
RMAN> RESTORE TABLESPACE customer;
Restore a specific datafile
RMAN> RESTORE DATAFILE ‘/dboracle/customer.dbf’;
Set destination directory for archive logs
RMAN> SET ARCHIVELOG destination to ‘/archives/’;
Restore all archive logs
RMAN> RESTORE ARCHIVELOG ALL;
Oracle RMAN vs. Export for Backups
Taking backups of a database is similar to exporting data, but backups are necessary for disaster recovery and must be done frequently to ensure business continuity. Backups should be secured and retained for at least two weeks. Archived data should be kept longer, but backups should be always available in case of media failure, corruption of data, or when data is accidentally deleted.
Exporting data takes a copy of data and stores it in another location, but it’s used when data from an Oracle database must be sent to another user or moved to a different environment. For example, exported data could be used to import information to a third-party MySQL database. Most exported data is a subset of data from an Oracle database such as data from a specific table or data matching specific search criteria.
Oracle RMAN vs. Export for Recovery
RMAN contains several features specific for backups and recovery. The agent lets administrators configure the software to run at specific times, encrypt data, and restore files and tables whenever necessary. It’s a critical component in business continuity to preserve data in case of a security event or production failure.
Exported data can be useful in case of data loss, but it’s cumbersome and isn’t reliable. The RMAN backup and restore process is specifically designed to organize and secure backups and recover data in as little time as possible. Any exported data could be used as a last resort, but restoring data from files is not recommended.
Benefits of Oracle RMAN
The Oracle RMAN tool has several features that make it a beneficial tool for database administrators. These features cannot be found in other applications, and most database applications are built for specific vendors. The Oracle RMAN tool is specifically designed for Oracle databases, and it’s included when you purchase the database engine and licenses.
A few beneficial features include:
- Scheduled or manual backups: Administrators can build a backup strategy from RMAN or manually take a snapshot of all data.
- Archived redo logs: If updates to a database corrupt data, archives can be used to roll back changes and restore data if a backup is inconsistent.
- Flash recovery: Oracle stores copies of data and archive logs in a specific directory. The flash recovery files can be used to quickly restore data and reduce downtime.
- Backup encryption: Encrypting backups adds a layer of security to sensitive business information, and it’s a compliance requirement for many businesses.
Disadvantages of Oracle RMAN
Administrators might see a few disadvantages with RMAN. The main one is its complexity and learning how to use all of its features. Administrators report that RMAN has a large learning curve for people unfamiliar with the application. It can take time for administrators to figure out how to build incremental backups, but once configurations are figured out, RMAN runs automatically with little intervention.
When to Use RMAN
Every organization should have a backup strategy for every critical system. A database is a critical resource required for business productivity, so it should be a priority. Backups are necessary for recovery if the database can no longer retrieve data after a server failure, data corruption, malware attacks, ransomware events, and accidental deletion of data. For some events, including ransomware, the only way to recover is by using backups.
Regular backups should be taken depending on the volume of data that changes throughout the day. The organization should determine how much data can be lost before an event affects business continuity and revenue. Use this information to create a baseline for backup frequency.
RMAN recovery options shouldn’t be needed often, but they’re necessary as a way to return a business environment back to its original state after an incident. For example, if ransomware encrypts database files, it’s impossible in most scenarios to decrypt files. RMAN can be used to recover data by restoring it from backups.