#!/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 进行执行!!