【识记】RMAN备份脚本
备份策略:
由于数据量仅仅有15GB左右,因此一周做4次全备;每天做2次归档日志备份。备份周期设置为7天
1.控制脚本
///////////////////////////////////////////////////// Start_Line /////////////////////////////////////////////////////
#!/bin/bash
#
############################################
export ORACLE_SID=db1
export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=/u01/app/oracle/product/11.2.0
DAY=`date +%F_%T`
CMDFILE=$1
LOGFILE=${CMDFILE}.${DAY}.log
RMAN=/u01/app/oracle/product/11.2.0/bin/rman
echo -e "[`date '+%F %T'`] $CMDFILE Start......" >> /backup/rman/scripts/time.txt
$RMAN target / nocatalog cmdfile=/backup/rman/scripts/$CMDFILE log=/backup/rman/scripts/log/$LOGFILE
echo -e "[`date '+%F %T'`] $CMDFILE End........" >> /backup/rman/scripts/time.txt
///////////////////////////////////////////////////// End_Line /////////////////////////////////////////////////////
2.全库备份脚本
///////////////////////////////////////////////////// Start_Line /////////////////////////////////////////////////////
run{
allocate channel d1 type disk;
allocate channel d2 type disk;
allocate channel d3 type disk;
allocate channel d4 type disk;
crosscheck backup;
crosscheck archivelog all;
sql 'alter system archive log current';
backup full database format '/backup/rman/dbf/full__%d_%s_%p_%u.bak';
sql 'alter system archive log current';
backup current controlfile format '/backup/rman/control/control_%s_%p_%t';
crosscheck backup;
delete noprompt expired backup;
delete obsolete;
delete noprompt backup of database completed before 'sysdate -7';
configure retention policy TO REDUNDANCY 2;
release channel d4;
release channel d3;
release channel d2;
release channel d1;
}
///////////////////////////////////////////////////// End_Line /////////////////////////////////////////////////////
3.归档日志备份
///////////////////////////////////////////////////// Start_Line /////////////////////////////////////////////////////
run{
allocate channel d1 type disk;
allocate channel d2 type disk;
sql 'alter system archive log current';
backup archivelog all format '/backup/rman/archivelog/archive_%t_%s' delete all input;
crosscheck archivelog all;
release channel d1;
release channel d2;
}
///////////////////////////////////////////////////// End_Line /////////////////////////////////////////////////////
4.使用方法:
24 00 * * 0,2,4,6 /backup/rman/scripts/rman_console.sh db.rcv
12 11,23 * * * /backup/rman/scripts/rman_console.sh archive.rcv