An example of Oracle RAMN backup solution

Source: Internet
Author: User

I used to share the RMAN backup script column in my blog. I used RMAN to back up the file to a local path, and then uploaded the backup file to the FTP server through FTP. Next, we will briefly introduce another RMAN backup solution. Below is a simple figure I have drawn (it is a little crude ).

First, back up the database to a directory on the local server (the directory is generated by date, and the retention period of the local backup depends on the storage situation. Generally, one day is enough ).

Then, upload the Backup file to the tape device through the Symantec Backup Exec 2012 Agent (disaster recovery Backup, tape Backup kept for 90 days ).

Finally, clean up the backup in the local backup path.

As shown above, there are only three steps and the overall idea is very simple. The following describes the specific script for implementation.

First, we will introduce the backup script backup_db_xxxx.sh (note that xxx is the name of the database instance. Many xxx files in the script need to be replaced according to specific scenarios, such as Instance name and email address)

   1: #********************************************************************************
   2: #  FileName     :               backup_db_xxxx.sh 
   3: #********************************************************************************
   4: #  Author       :               Tommy
   5: #  CreateDate   :               2012-07-18
   6: #  Description  :               this script is backup the oracle database by rman
   7: #********************************************************************************
8: # Parameters: parameter description
   9: #********************************************************************************
10: # This script has no parameters and can be called directly.
  11: #********************************************************************************
  12: #      Modified Date    Modified User     Version            Modified Reason
  13: #********************************************************************************
14: #2014-04-26 Kerry V1.0.1 script part, adjust the script format
  15: # 
  16: #********************************************************************************
  17:  
  18:  
  19:  
  20: #REM - USER DEFINED VARIABLES -
  21: export DATESTAMP=`date '+%F'`
  22:  
  23: #REM - Oracle specific settings: -
  24: . /home/oracle/.bash_profile
  25: export CATALOG=NOCATALOG
  26:  
  27: #REM - Specify the Logfiles -
  28: export BACKUP_FULL_LOG=/u04/backup/backuplogs/rman_backup_db_xxx_$DATESTAMP.log
  29:  
  30: #REM - BACKUP SECTION -
  31: echo $BACKUP_FULL_LOG
  32: rman target / $CATALOG cmdfile=/u04/backup/scripts/backup_db_xxx.rcv log=$BACKUP_FULL_LOG
  33:  
  34: EMAILTMP=/u04/backup/backuplogs/rman_backup_db_xxx_$DATESTAMP.TMP
  35:  
  36: ######################## config email parameters ##########################
  37: echo 'Content-Type: text/html' > $EMAILTMP
  38: echo 'To: xxx@xxx.com, xxx@xxx.com,xxx@xxx.com' >> $EMAILTMP
  39: echo 'Subject : Backup Status - xxxx(RMAN hot backup)' >> $EMAILTMP
  40: echo '<pre>  41: ###########################################################################
  42:  
  43: echo "=======================================================" >> $EMAILTMP
  44: echo "================ Daily Backup for xxxx ================" >> $EMAILTMP
  45: echo "=======================================================" >> $EMAILTMP
  46: echo " " >> $EMAILTMP 
  47:  
  48: cat $BACKUP_FULL_LOG >> $EMAILTMP 2>&1
  49: echo " " >> $EMAILTMP 
  50: echo "================ End of Rman Backup ==================" >> $EMAILTMP
  51: echo "======================================================" >> $EMAILTMP
  52:  
  53: /usr/sbin/sendmail -t -f "BackupAdmin" < $EMAILTMP
  54: rm $EMAILTMP
The backup_db_xxx.rcv file is actually the RMAN command file (called in backup_db_xxxx.sh ). As shown below
   1: run {
   2: CONFIGURE RETENTION POLICY TO REDUNDANCY 2; # default
   3: CONFIGURE BACKUP OPTIMIZATION ON;
   4: CONFIGURE DEFAULT DEVICE TYPE TO DISK; # default
   5: CONFIGURE CONTROLFILE AUTOBACKUP ON;
   6: CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '/u04/backup/backupsets/ora_cf%F';
   7: CONFIGURE DEVICE TYPE DISK PARALLELISM 1 BACKUP TYPE TO BACKUPSET; # default
   8: CONFIGURE DATAFILE BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
   9: CONFIGURE ARCHIVELOG BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
  10: CONFIGURE CHANNEL DEVICE TYPE DISK FORMAT '/u04/backup/backupsets/ora_df%t_s%s_s%p';
  11: CONFIGURE MAXSETSIZE TO UNLIMITED; # default
  12: CONFIGURE ENCRYPTION FOR DATABASE OFF; # default
  13: CONFIGURE ENCRYPTION ALGORITHM 'AES128'; # default
  14: CONFIGURE ARCHIVELOG DELETION POLICY TO NONE; # default
  15: sql 'alter system archive log current';
  16: backup as compressed backupset database plus archivelog delete input;
  17: copy current controlfile to '/u04/backup/backupsets/controlfile.copy';
  18: }
  19: exit

The delete_obj_xxxx.sh file is as follows:

   1: #*****************************************************************************************
   2: #  FileName     :               delete_obj_xxxx.sh 
   3: #*****************************************************************************************
   4: #  Author       :               Tommy
   5: #  CreateDate   :               2012-07-18
   6: #  Description  :               this script is delete the obsolete object through rman
   7: #*****************************************************************************************
8: # Parameters: parameter description
   9: #*****************************************************************************************
10: # This script has no parameters and can be called directly.
  11: #*****************************************************************************************
  12: #      Modified Date    Modified User     Version            Modified Reason
  13: #*****************************************************************************************
14: #2014-04-26 Kerry V1.0.1 modify some parts of the script and adjust the script format
  15: # 
  16: #                               
  17: #                               
  18: #*****************************************************************************************
  19:  
  20:  
  21: #REM - USER DEFINED VARIABLES -
  22: export DATESTAMP=`date '+%F'`
  23:  
  24: #REM - Oracle specific settings: -
  25: . /home/oracle/.bash_profile
  26: export CATALOG=NOCATALOG
  27:  
  28: #REM - Specified the logfiles -
  29: export BACKUP_FULL_LOG=/u04/backup/backuplogs/rman_delete_ob_xxx_$DATESTAMP.log
  30:  
  31: #REM - BACKUP SECTION -
  32: echo $BACKUP_FULL_LOG
  33: rman target / $CATALOG cmdfile=/u04/backup/scripts/delete_ob_xxx.rcv log=$BACKUP_FULL_LOG

The/u04/backup/scripts/delete_ob_xxx.rcv file is the recovery file of RMAN, as shown below:

   1: run {
   2: CONFIGURE RETENTION POLICY TO REDUNDANCY 2; # default
   3: CONFIGURE BACKUP OPTIMIZATION ON;
   4: CONFIGURE DEFAULT DEVICE TYPE TO DISK; # default
   5: CONFIGURE CONTROLFILE AUTOBACKUP ON;
   6: CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '/u04/backup/backupsets/ora_cf%F';
   7: CONFIGURE DEVICE TYPE DISK PARALLELISM 1 BACKUP TYPE TO BACKUPSET; # default
   8: CONFIGURE DATAFILE BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
   9: CONFIGURE ARCHIVELOG BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
  10: CONFIGURE CHANNEL DEVICE TYPE DISK FORMAT '/u04/backup/backupsets/ora_df%t_s%s_s%p';
  11: CONFIGURE MAXSETSIZE TO UNLIMITED; # default
  12: CONFIGURE ENCRYPTION FOR DATABASE OFF; # default
  13: CONFIGURE ENCRYPTION ALGORITHM 'AES128'; # default
  14: CONFIGURE ARCHIVELOG DELETION POLICY TO NONE; # default
  15: sql 'alter system archive log current';
  16: delete obsolete;
  17: }

Then configure the job in the crontab job.

15 00 ***/u04/backup/scripts/backup_db_xxx.sh>/dev/null 2> & 1

00 08 ***/u04/backup/scripts/delete_ob_xxx.sh>/dev/null 2> & 1

Someone may ask, isn't Symantec Backup Exec Agent carrying the Backup file? In fact, you need to install Symantec Backup Exec 2012 Agent on the Linux server first, for more information, see how to install Symantec Backup Exec 2012 Agent For Linux. Specify Symantec Backup Exec Server in the configuration file, and then you only need to set a job scheduled Backup file on the Server. There is nothing to say.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.