Rman Backup and delete archive scripts

Source: Internet
Author: User

After a period of observation found that two local and remote two dataguard run relatively stable, so decided to put the day-to-day backup on the Datagurad.

To share the pressure of the main library. The main library only makes full backups on a regular basis.

Backup scripts: rman_back.sh

Because the database is relatively small, do not do incremental backup, directly done a full backup.

#!/bin/bash
export Oracle_base=/u01/ora
export oracle_home= $ORACLE _base/product/11.2.3/db_1
Export ORACLE_SID=ORCLPRD
export path=/usr/sbin: $ORACLE _home/bin: $PATH

rman target/<<eof
run{
Backup Database 
Skip inaccessible 
plus archivelog 
filesperset 
}

Allocate channel for maintenance device type disk;
Crosscheck backupset;
Delete noprompt obsolete;
Exit;
Eof

Grant rman_back.sh to Oracle users for permission to execute

chmod  744 rman_back.sh 



Add a backup script to the crontab

Crontab-e

* *  sh  /u01/ora/backup/rman_back.sh >>/u01/ora/backup/rman_back.log



To delete an archive script:
More rman_del_archivelog.sh

#!/bin/bash
export Oracle_base=/u01/ora
export oracle_home= $ORACLE _base/product/11.2.3/db_1
Export ORACLE_SID=ORCLPRD
export path=/usr/sbin: $ORACLE _home/bin: $PATH

rman  target/  <<eof
Crosscheck Archivelog all;
Delete noprompt expired archivelog all;
Delete noprompt Archivelog until time ' sysdate-7 ';
Exit;
Eof

More del_archivelog.sh

#!/bin/bash
##### logfile=/u01/ora/arch01/del_archive.log

date= ' date +%y-%m-%d:%h:%m:%s '
echo--- -------Begin Delete archivelog $date----------" 
sh  /u01/ora/arch01/rman_del_archivelog.sh  
echo"--- -------End   Delete archivelog $date----------"
date



Add the Delete archive script to the crontab

Crontab-e

* *   sh  /u01/ora/arch01/del_archivelog.sh  >>/u01/ora/arch01/del_archive.log


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.