前2天给公司的测试库写了个shell备份脚本,复杂的不会写,只能先从简单的入手,现贴出脚本文件供大家学习参考,有不对的地方也请大家多多指出!
RMAN 增量备份shell脚本
原创
©著作权归作者所有:来自51CTO博客作者a3z2008的原创作品,请联系作者获取转载授权,否则将追究法律责任
#”————————sunday———————————-”
source /home/oracle/.bash_profile
$ORACLE_HOME/bin/rman <<EOF
connect 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;
EOF
echo “————————-end——————————”;date
#”————————monday———————————-”
source /home/oracle/.bash_profile
$ORACLE_HOME/bin/rman <<EOF
connect 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;
EOF
echo “————————-end——————————”;date
#”————————tuesday———————————-”
source /home/oracle/.bash_profile
$ORACLE_HOME/bin/rman <<EOF
connect 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;
EOF
echo “————————-end——————————”;date
#”————————wendesday———————————-”
source /home/oracle/.bash_profile
$ORACLE_HOME/bin/rman <<EOF
connect 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;
EOF
echo “————————-end——————————”;date
#”————————thursday———————————-”
source /home/oracle/.bash_profile
$ORACLE_HOME/bin/rman <<EOF
connect 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;
EOF
echo “————————-end——————————”;date
#”————————Friday———————————-”
source /home/oracle/.bash_profile
$ORACLE_HOME/bin/rman <<EOF
connect 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;
EOF
echo “————————-end——————————”;date
#”————————saturday———————————-”
source /home/oracle/.bash_profile
$ORACLE_HOME/bin/rman <<EOF
connect 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;
EOF
echo “————————-end——————————”;date
把每天的脚本代码写进一个sh文件然后设置crontab
crontab如下
10 1 * * 0 /u01/crontab_bp_shell/sunday_bp.sh
10 1 * * 1 /u01/crontab_bp_shell/monday_bp.sh
10 1 * * 2 /u01/crontab_bp_shell/tuesday_bp.sh
10 1 * * 3 /u01/crontab_bp_shell/wendesday_bp.sh
10 1 * * 4 /u01/crontab_bp_shell/thursday_bp.sh
10 1 * * 5 /u01/crontab_bp_shell/friday_bp.sh
10 1 * * 6 /u01/crontab_bp_shell/saturday_bp.sh
好了,一个简单的备份策略就这样出来了!
上一篇:Oracle 10g手动建库
提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章
-
shell脚本 rman备份
shell脚本中的rman备份
RMAN shell oracle -
rman备份脚本shell版
本文主要介绍常用的rman备份脚本。
rman 脚本 shell -
ORACLE-RMAN:备份脚本(全库,增量)
RMAN备份脚本
database target product local -
【Oracle数据库】RMAN增量备份脚本
Oracle数据库如何配置rman增量脚本?
DBA Oracle 数据库 oracle backup -
RMAN 增量备份 脚本
#
oracle hive sql