假设每周备份两次全备份,其他时间备份归档日志,时间为凌晨3:00.备份位置需要精心设置,一般都是与数据文件在不同的磁盘,同时也需要冗余度。
定时设置
30 3 * * 0-6 /opt/oracle/dbmon/rmanbak/startrman.sh
######begin备份调度脚本#####
./home/oracle/.bash_profile
SH_HOME=/opt/oracle/dbmon/rmanbak
export SH_HOME
DATE=`date +"%Y%m%d"`
week=`date +"%w"`
#-------------------------------------
#Confirm wheher the oracle is runing
#--------------------------------------
ps -ef|grep dbw0_$ORACLE_SID |grep -v grep >>/dev/null
#--------------------------------------
#Begin to backup
#----------------------------------------
if [ $? -eq 0 ]; then
if [ $week = "0" ] || [ $week = "3" ];then
rman target / @$SH_HOME/fullback.sql log=$SH_HOME/logs/fullbk`date +"%Y%m%d"`.log
else
rman target / @$SH_HOME/archback.sql log=$SH_HOME/logs/fullbk`date +"%Y%m%d"`.log
fi
fi
######end备份调度脚本#####
#######begin全备份脚本##############
run{
backup full tag ‘order‘ database
include current controlfile
format ‘/home/oracle/backup/orderfullback_%d_%T_%s‘
plus archivelog
format ‘/home/oracle/backup/orderarch_%d_%T_%s‘ delete all input;
delete noprompt obsolete;
}
#######end全备份脚本##############
#######begin归档备份脚本##############
run{
backup archivelog all
format ‘/home/oracle/orderarch_%d_%T_%s‘ delete all input;
}
#######end归档备份脚本##############
Rman的备份保留策略
CONFIGURE RETENTION POLICY TO REDUNDANCY 3;