分享

oracle增量备份脚本

 168一路发 2012-09-12
【 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 <<EOF
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 <<EOF
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 <<EOF
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

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多