【 0级全库备份 】
#!/bin/bash
export ORACLE_SID=ora10
export ORACLE_BASE=/ora10g
export ORACLE_HOME=$ORACLE_BASE/product/10.2.0
date=`date +%y-%m-%d`
logdir=/script/log/
[ -d "$logdir" ] || mkdir -p $logdir
/ora10g/product/10.2.0/bin/rman catalog rman/rman123 target rman/rman@dic10 log="$logdir"/"$date"_10_inc0.log <
run {
allocate channel ch1 device type disk;
allocate channel ch2 device type disk;
allocate channel ch3 device type disk;
allocate channel ch4 device type disk;
allocate channel ch5 device type disk;
allocate channel ch6 device type disk;
allocate channel ch7 device type disk;
allocate channel ch8 device type disk;
sql 'alter system archive log current';
backup incremental level 0 database format '/backup/data/0_LEVEL_FULL_DATABASE_%T_%s.ful';
backup archivelog all format '/backup/data/ARCHIVE_LOG_%T_%s.arc' delete all input;
backup current controlfile format '/backup/data/CONTROL_FILE_%T_%s.ctl';
crosscheck backup;
crosscheck archivelog all;
delete noprompt expired backup;
delete noprompt obsolete;
release channel ch1;
release channel ch2;
release channel ch3;
release channel ch4;
release channel ch5;
release channel ch6;
release channel ch7;
release channel ch8;
}
EOF
【 一级差异增量备份 】
#!/bin/bash
export ORACLE_SID=ora10
export ORACLE_BASE=/ora10g
export ORACLE_HOME=$ORACLE_BASE/product/10.2.0
date=`date +%y-%m-%d`
logdir=/script/log/
[ -d "$logdir" ] || mkdir -p $logdir
/ora10g/product/10.2.0/bin/rman catalog rman/rman123 target rman/rman@dic10 log="$logdir"/"$date"_10_inc1.log <
run {
allocate channel ch1 device type disk;
allocate channel ch2 device type disk;
allocate channel ch3 device type disk;
allocate channel ch4 device type disk;
allocate channel ch5 device type disk;
allocate channel ch6 device type disk;
allocate channel ch7 device type disk;
allocate channel ch8 device type disk;
sql 'alter system archive log current';
backup incremental level 1 database format '/backup/data/1_LEVEL_INCREMENTAL_DATABASE_%T_%s.ful';
backup archivelog all format '/backup/data/ARCHIVE_LOG_%T_%s.arc' delete all input;
backup current controlfile format '/backup/data/CONTROL_FILE_%T_%s.ctl';
crosscheck archivelog all;
delete noprompt archivelog all;
release channel ch1;
release channel ch2;
release channel ch3;
release channel ch4;
release channel ch5;
release channel ch6;
release channel ch7;
release channel ch8;
}
EOF
【 二级差异增量备份 】
#!/bin/bash
export ORACLE_SID=ora10
export ORACLE_BASE=/ora10g
export ORACLE_HOME=$ORACLE_BASE/product/10.2.0
date=`date +%y-%m-%d`
logdir=/script/log
[ -d "$logdir" ] || mkdir -p $logdir
/ora10g/product/10.2.0/bin/rman catalog rman/rman123 target rman/rman@dic10 log="$logdir"/"$date"_10_inc2.log <
run {
allocate channel ch1 device type disk;
allocate channel ch2 device type disk;
allocate channel ch3 device type disk;
allocate channel ch4 device type disk;
allocate channel ch5 device type disk;
allocate channel ch6 device type disk;
allocate channel ch7 device type disk;
allocate channel ch8 device type disk;
sql 'alter system archive log current';
backup incremental level 2 database format '/backup/data/2_LEVEL_INCREMENTAL_DATABASE_%T_%s.ful';
backup archivelog all format '/backup/data/ARCHIVE_LOG_%T_%s.arc' delete all input;
backup current controlfile format '/backup/data/CONTROL_FILE_%T_%s.ctl';
crosscheck archivelog all;
delete noprompt archivelog all;
release channel ch1;
release channel ch2;
release channel ch3;
release channel ch4;
release channel ch5;
release channel ch6;
release channel ch7;
release channel ch8;
}
EOF