#!/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