您的位置:首页 > 运维架构 > Shell

RMAN 增量备份shell脚本

2014-01-24 11:26 447 查看
前2天给公司的测试库写了个shell备份脚本,复杂的不会写,只能先从简单的入手,现贴出脚本文件供大家学习参考,有不对的地方也请大家多多指出!#”————————sunday———————————-”source /home/oracle/.bash_profile$ORACLE_HOME/bin/rman <<EOFconnect target /run{allocate channel d1 type disk;allocate channel d2 type disk;backup incremental level 0 database format ‘/u02/rman/full_0_%u.bak’;backup archivelog all format ‘/u02/rman/arch_%u.bak’;backup current controlfile format ‘/u02/rman/control_%u.bak’;release channel d1;release channel d2;}list backup;crosscheck backup;delete noprompt expired backup;delete noprompt obsolete;exit;EOFecho “————————-end——————————”;date#”————————monday———————————-”source /home/oracle/.bash_profile$ORACLE_HOME/bin/rman <<EOFconnect target /run{allocate channel d1 type disk;allocate channel d2 type disk;backup incremental level 1 database format ‘/u02/rman/bp_1_%u.bak’;backup archivelog all format ‘/u02/rman/arch_%u.bak’;backup current controlfile format ‘/u02/rman/control_%u.bak’;release channel d1;release channel d2;}crosscheck backup;delete noprompt expired backup;delete noprompt obsolete;exit;EOFecho “————————-end——————————”;date#”————————tuesday———————————-”source /home/oracle/.bash_profile$ORACLE_HOME/bin/rman <<EOFconnect target /run{allocate channel d1 type disk;allocate channel d2 type disk;backup incremental level 1 database format ‘/u02/rman/bp_1_%u.bak’;backup archivelog all format ‘/u02/rman/arch_%u.bak’;backup current controlfile format ‘/u02/rman/control_%u.bak’;release channel d1;release channel d2;}crosscheck backup;delete noprompt expired backup;delete noprompt obsolete;exit;EOFecho “————————-end——————————”;date#”————————wendesday———————————-”source /home/oracle/.bash_profile$ORACLE_HOME/bin/rman <<EOFconnect target /run{allocate channel d1 type disk;allocate channel d2 type disk;backup incremental level 2 database format ‘/u02/rman/bp_2_%u.bak’;backup archivelog all format ‘/u02/rman/arch_%u.bak’;backup current controlfile format ‘/u02/rman/control_%u.bak’;release channel d1;release channel d2;}crosscheck backup;delete noprompt expired backup;delete noprompt obsolete;exit;EOFecho “————————-end——————————”;date#”————————thursday———————————-”source /home/oracle/.bash_profile$ORACLE_HOME/bin/rman <<EOFconnect target /run{allocate channel d1 type disk;allocate channel d2 type disk;backup incremental level 1 database format ‘/u02/rman/bp_1_%u.bak’;backup archivelog all format ‘/u02/rman/arch_%u.bak’;backup current controlfile format ‘/u02/rman/control_%u.bak’;release channel d1;release channel d2;}crosscheck backup;delete noprompt expired backup;delete noprompt obsolete;exit;EOFecho “————————-end——————————”;date#”————————Friday———————————-”source /home/oracle/.bash_profile$ORACLE_HOME/bin/rman <<EOFconnect target /run{allocate channel d1 type disk;allocate channel d2 type disk;backup incremental level 2 database format ‘/u02/rman/bp_2_%u.bak’;backup archivelog all format ‘/u02/rman/arch_%u.bak’;backup current controlfile format ‘/u02/rman/control_%u.bak’;release channel d1;release channel d2;}crosscheck backup;delete noprompt expired backup;delete noprompt obsolete;exit;EOFecho “————————-end——————————”;date#”————————saturday———————————-”source /home/oracle/.bash_profile$ORACLE_HOME/bin/rman <<EOFconnect target /run{allocate channel d1 type disk;allocate channel d2 type disk;backup incremental level 1 database format ‘/u02/rman/bp_1_%u.bak’;backup archivelog all format ‘/u02/rman/arch_%u.bak’;backup current controlfile format ‘/u02/rman/control_%u.bak’;release channel d1;release channel d2;}crosscheck backup;delete noprompt expired backup;delete noprompt obsolete;exit;EOFecho “————————-end——————————”;date把每天的脚本代码写进一个sh文件然后设置crontabcrontab如下10 1 * * 0 /u01/crontab_bp_shell/sunday_bp.sh10 1 * * 1 /u01/crontab_bp_shell/monday_bp.sh10 1 * * 2 /u01/crontab_bp_shell/tuesday_bp.sh10 1 * * 3 /u01/crontab_bp_shell/wendesday_bp.sh10 1 * * 4 /u01/crontab_bp_shell/thursday_bp.sh10 1 * * 5 /u01/crontab_bp_shell/friday_bp.sh10 1 * * 6 /u01/crontab_bp_shell/saturday_bp.sh好了,一个简单的备份策略就这样出来了!
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  rman