ORACLE 10G rman 备份脚本

#!/bin/bash

back_path="/10g/backup";

back_log="/10g/backup/log";

rman_name=“cisco”;

rman_pw="rman";

rman_log_name="rman";

rman_log_pass="cisco";

rman_sid=“zsh1”;

rman_bin=/opt/oracle/product/9.2.0.4/bin

date_w=`date +%w`;

 

case $date_w in

 

5) #指的是周五执行

$rman_bin log $back_log/level0_`date +%Y-%m-%d`.log <<EOF

connect target $rman_name/$rman_pw

run {

allocate channel d1 type disk;

allocate channel d2 type disk;

backup full database format '$back_path/`date +%Y%m%d`_full_%d_%s_%p_%u.bak'

tag='full' include current controlfile;

sql 'alter system archive log current';

backup archivelog all format '$back_path/`date +%Y%m%d`_archivelog_%d_%s_%p_%u.bak' delete all input;

release channel d2;

release channel d1;

}

crosscheck backup;

delete noprompt expired backup;

delete noprompt obsolete;

exit

EOF

;;

#以上是完全备份

 

7)  #指的是周日执行

$rman_bin log $back_log/level0_`date +%Y-%m-%d`.log <<EOF

connect catalog $rman_log_name/$rman_log_pass

connect target $rman_name/$rman_pw

run {

allocate channel d1 type disk;

allocate channel d2 type disk;

backup incremental level 0 database format '$back_path/`date +%Y%m%d`_level0_%d_%s_%p_%u.bak'

tag='level 0' include current controlfile;

sql 'alter system archive log current';

backup archivelog all format '$back_path/`date +%Y%m%d`_archivelog_%d_%s_%p_%u.bak' delete all input;

release channel d2;

release channel d1;

}

crosscheck backup;

delete noprompt expired backup;

delete noprompt obsolete;

resync catalog;

exit

EOF

;;

#以上是0级备份

 

3) #指的是周三执行

$rman_bin log $back_log/level1_`date +%Y-%m-%d`.log <<EOF

connect catalog $rman_log_name/$rman_log_pass

connect target $rman_name/$rman_pw

run {

allocate channel d1 type disk;

backup incremental level 1 format '$back_path/`date +%Y%m%d`_level1_%d_%s_%p_%u.bak' tag = 'level 1' database;

sql 'alter system archive log current';

backup archivelog all format '$back_path/`date +%Y%m%d`_archivelog_%d_%s_%p_%u.bak' delete all input;

release channel d1;

}

crosscheck backup;

delete noprompt expired backup;

delete noprompt obsolete;

resync catalog;

exit;

EOF

;;

#以上是1级备份

1|2|4|5|6)   #指的是周一,二,四,五,六执行

$rman_bin log $back_log/level2_`date +%Y-%m-%d`.log <<EOF

connect catalog $rman_log_name/$rman_log_pass

connect target $rman_name/$rman_pw

 

 

利用LINUX 的crintab 进行执行!!


 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

七七powerful

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值