RMAN进行数据库备份策略脚本.SH

1 创建如下crontab

crontab -e
0 1 * * * /u01/rman/rman.sh

2 实施脚本如下:


#!/bin/bash 
. /etc/profile
. /home/oracle/.bash_profile

wk=`date +%w`
level=1
case $wk in 
[1-6]) level=1;;
0) level=0;;
esac; 
level=0
echo the current week is $wk ,you should be rman incremental level $level backupset  
rm -f /u01/rman/spfile.bak 
rm -f /u01/rman/ctl.bak 
rm -f /u01/rman/*.log 
rman target / trace=/u01/rman/db_$level.log<< eof
run{
allocate channel c1 device type disk;
allocate channel c2 device type disk;
allocate channel c3 device type disk;
allocate channel c4 device type disk;
backup as compressed backupset incremental level $level database format '/u01/rman/db_%U_%Y_%M_%D.bak' plus archivelog format '/u01/rman/arc_%U_%Y_%M_%D.bak'  delete in
put; 
crosscheck backup;
release channel c1; 
release channel c2; 
release channel c3; 
release channel c4; 
}
backup spfile format '/u01/rman/spfile.bak'; 
backup current controlfile format '/u01/rman/ctl.bak'; 
delete noprompt obsolete;
delete noprompt expired backup; 
exit; 
eof

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值