rman 备份脚本

本文介绍了一种使用 Oracle RMAN 进行自动备份的方法,包括每周不同时间点进行全备份、差量备份和增量备份的具体步骤。通过编写备份脚本结合 Linux 下的 crontab 实现自动化的备份计划。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

oracle rnam 备份方案

周日晚上 oracle$>rman target / msglog=/u01/rmanbak/bakl0.log cmdfile=/u01/rmanbak/script/bakl0

周一晚上 oracle$>rman target / msglog=/u01/rmanbak/bakl1.log cmdfile=/u01/rmanbak/script/bakl1

周二晚上 oracle$>rman target / msglog=/u01/rmanbak/bakl2.log cmdfile=/u01/rmanbak/script/bakl2

周三晚上 oracle$>rman target / msglog=/u01/rmanbak/bakl3.log cmdfile=/u01/rmanbak/script/bakl3

周四晚上 oracle$>rman target / msglog=/u01/rmanbak/bakl4.log cmdfile=/u01/rmanbak/script/bakl4

周五晚上 oracle$>rman target / msglog=/u01/rmanbak/bakl5.log cmdfile=/u01/rmanbak/script/bakl5

周六晚上 oracle$>rman target / msglog=/u01/rmanbak/bakl6.log cmdfile=/u01/rmanbak/script/bakl6

注 level 0 全备份;level 2 增量备份; level 1  差量备份 参照http://www.itpub.net/658332.html

 

自动备份: 备份脚本+ linux下的crontab

在redhat linux 的 u01/rmanbak/script/目录下新建下面文件

bakl0 文件

run{

allocate channel c1 type disk;

backup incremental level 0 format "/u01/rmanbak/inc0_%u_%T" tag monday_inc0 database;

release channel c1;

}

bakl1 文件

run{

allocate channel c1 type disk;

backup incremental level 1 format "/u01/rmanbak/inc1_%u_%T" tag monday_inc0 database;

release channel c1;

}

bakl2 文件

run{

allocate channel c1 type disk;

backup incremental level 2 format "/u01/rmanbak/inc2_%u_%T" tag monday_inc0 database;

release channel c1;

}

执行脚本:

rman target / msglog=/u01/rmanbak/bakl0.log cmdfile=/u01/rmanbak/script/bakl0

rman target / msglog=/u01/rmanbak/bakl1.log cmdfile=/u01/rmanbak/script/bakl1

rman target / msglog=/u01/rmanbak/bakl2.log cmdfile=/u01/rmanbak/script/bakl2

 

编辑oracle用户自动执行计划

crontab 命令用法参照 : http://blog.youkuaiyun.com/yuanfeiyan/archive/2007/10/15/1825288.aspx

crontab -e -u oracle

 

内容:

30 23 * * 0 rman target / msglog=/u01/rmanbak/bakl0.log cmdfile=/u01/rmanbak/script/bakl0

30 23 * * 1 rman target / msglog=/u01/rmanbak/bakl0.log cmdfile=/u01/rmanbak/script/bakl2

30 23 * * 2 rman target / msglog=/u01/rmanbak/bakl0.log cmdfile=/u01/rmanbak/script/bakl2

30 23 * * 3 rman target / msglog=/u01/rmanbak/bakl0.log cmdfile=/u01/rmanbak/script/bakl1

30 23 * * 4 rman target / msglog=/u01/rmanbak/bakl0.log cmdfile=/u01/rmanbak/script/bakl2

30 23 * * 5 rman target / msglog=/u01/rmanbak/bakl0.log cmdfile=/u01/rmanbak/script/bakl2

30 23 * * 6 rman target / msglog=/u01/rmanbak/bakl0.log cmdfile=/u01/rmanbak/script/bakl2

 

注释:30 23 * * 0 表示 30分 23点 *日期 *月 0星期天

-e 编辑用户的Crontab文件

 

 

重启crontab 命令 : service cronb restart

 

如果不能执行。原因1、脚本是否是可执行脚本。2、oracle环境变量问题。 解决办法是在写个shall让crontab调用例如

a1、bakup1.sh  
rq=`date '+%y%m%d'`; 
export ORACLE_HOME=/opt/app/oracle/9.2.0;
export ORACLE_SID=zhang;
export ORACLE_BASE=/opt/app/oracle;
export PATH=$ORACLE_HOME/bin;$PATH;
/opt/app/oracle/9.2.0/bin/rman target / msglog=/home/oracle/oraBak/autoBak/bakup1_$rq.log cmdfile=/home/oracle/oraBak/script/bakup2

 

From:http://hi.baidu.com/shulei1234/blog/item/f63c433ee84e10d67c1e71c0.html

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值