Oracle Rman backup script with automatic deletion of duplicate backup files

Source: Internet
Author: User

#!/bin/shsource/home/oracle/.bash_profileif [-Z]then echo "please Input a number,usage:0|1|2" Exitelse Rman_leve L=$1fiexport oracle_sid=xxxxexport today= ' date ' +%y%m%d ' export rman_dir=/backup/archivelog/rman/$ORACLE _sid/$ today-$RMAN _levelmkdir-p $RMAN _dircd $RMAN _dirlogfile=ora_rman_bk_$oracle_sid-l$rman_level-' date ' +%y%m%d '. log# Rman backup Rman target/msglog= $RMAN _dir/$LogFile <<eofdelete noprompt obsolete; CONFIGURE BACKUP optimization on; CONFIGURE Controlfile autobackup on; CONFIGURE controlfile autobackup FORMAT for DEVICE type DISK to ' $RMAN _dir/cf%f '; run {allocate channel C1 type Disk;alloca Te Channel C2 type Disk;backup as compressed backupset incremental level $RMAN _level filesperset 3 tag ' dbl$rman_level ' fo Rmat ' $RMAN _dir/ora_o_%d_%t%s%p%u ' database skip readonly include current Controlfile;sql ' alter system archive log Curren T '; backup (archivelog all format ' $RMAN _dir/ora_a_%d_%t%s%p%u ' delete input); release channel C1;release channel C2;} List Backup;exIt Eof#mail backup Logmail-s "$ORACLE _sid rman l$rman_level BACKUP Log $TODAY" [email protected] < $RMAN _dir/$LogFi Le

By the way, a mouth:Delete noprompt obsolete differs from delete obsoletenoprompt: Without prompting, there is no need to confirm "yes or no" for the originating delete command in the shell script.

set the following in Crontab:0 4 * * 5 sh/backup/scripts/oracle/oracle_rman_bak.sh 0 >/backup/archivelog/logs/rman.log 2>&1
0 4 * * 2 sh/backup/scripts/oracle/oracle_rman_bak.sh 1 >/backup/archivelog/logs/rman.log 2>&1

make an incremental and level 0 backup once a week.

Oracle Rman backup script with automatic deletion of duplicate backup files

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.