Oracle Rman Backup

Oracle RMAN or the Recovery Manager is the tool provided by Oracle to perform all its database related data protection operations. This include Rman Backups, Restorations and recovery, Flashback, Backup encryption, Duplication and other numerous options. Although a comprehensive article on Rman can be a complex topic, idea of this post is to provide basic understanding of configuring a Oracle rman backup with minimal database administration knowledge.

Oracle Backup Types – Online (Hot) Backups and Offline (Cold) Backups

Rman backup can be either Online backup where backups is taken while the database is open for users and applications to connect and work. Offline backups are a dying concept as more and more systems are not tolerating downtimes to take backups. In order to take online rman backup the database must be in archive log mode.
 SQL> select log_mode from v$database;  
 LOG_MODE  
 ------------  
 ARCHIVELOG  
 SQL>  
  • Setting the Oracle database to archivelog mode - https://www.oracle.com/ocom/groups/public/@otn/documents/webcontent/283263.htm
Other than above mentioned, Oracle rman backups can be categorized based on the backup criteria, such full backups, incremental backups, tablespace level, table level etc. For the scope of the document we are referring to full backups here.

Rman Backup Script

Below is a simple Rman backup script which can be used to take a full backup of the database. Purpose of including the script is to discuss the same line by line in order to understand the Rman backup procedure.
 export ORACLE_HOME=/u01/db_1  
 export ORACLE_SID=MIS  
 export PATH=$PATH:$ORACLE_HOME/bin  
 export LD_LIBRARY_PATH=/u01/db_1/lib  
 DPATH=/backup/`date +%Y-%m-%d`  
 mkdir $DPATH  
 chmod -R 777 $DPATH  
 chown oracle:oinstall $DPATH  
 RUN {  
 crosscheck archivelog all;  
 delete archivelog all backed up 1 times to device type disk;  
 CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '$DPATH/%F';  
 ALLOCATE CHANNEL disk1 DEVICE TYPE DISK MAXPIECESIZE 1500M;  
 ALLOCATE CHANNEL disk2 DEVICE TYPE DISK MAXPIECESIZE 1500M;  
 BACKUP FORMAT '$DPATH/bk_u%u_s%s_p%p_t%t' DATABASE plus archivelog;  
 release channel disk1;  
 release channel disk2;  
 }  

Exports and other bash commands

- This is to setup the environment for the script. Example is from a Solaris Rman setup and it creates a location on the server to store the Rman backup files. (DPATH==/backup/MIS/`date +%Y-%m-%d`). So daily backups are stored in this folder under the date.
we need to make sure this backup mount point is not from the same storage as the database itself. Other wise a failure in the storage would cause both the database it self and the backups to be lost.

RMAN Run Block

- First two commands of the scripts are for managing the archive logs, which deletes the archivelogs that are already backed up.
Next are the channel allocations. Rman backup client use these channels to backups the database. channel can be tape or disk device based on the backup media used. Here 2 backup channels are declared while setting max backup piece size per channel to 1.5 GB.
Next BACKUP FORMAT '$DPATH/bk_u%u_s%s_p%p_t%t' DATABASE plus archivelog; does perform the actual backup operation. It uses the DPATH location variable to store the backup pieces and the archive logs.
Finally, the two channels are closed by rman.
By scheduling similar script Oracle database can be backed up daily full basis to a given disk location on the servers. By including the archive logs to the Rman backup we are adding the PITR (Point in time Reco every) capability. This allows Rman to recover the restored database from the backups to exact point in time even after the full backup completion time, which minimizes the possible data lose.

Comments

Popular posts from this blog

ORA-16433: The database or pluggable database must be opened in read/write

Oracle Multitenant - Create new service for PDB using DBMS_SERVICE

Wait for unread message on broadcast channel - Blocking Sessions