分享

RMAN备份脚本

 wghbeyond 2011-01-18
#!/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
 

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多