rman 脚本 level 0:
[oracle@oracle scripts]$ cat rman_level0.rcv
connect target /
run{
CONFIGURE CONTROLFILE AUTOBACKUP ON;
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '/u02/rmback/data/%F.ctl';
ALLOCATE CHANNEL CH1 DEVICE TYPE DISK FORMAT '/u02/rmback/data/%T_%U.bak' maxpiecesize 4g;
ALLOCATE CHANNEL CH2 DEVICE TYPE DISK FORMAT '/u02/rmback/data/%T_%U.bak' maxpiecesize 4g;
BACKUP INCREMENTAL LEVEL 0 TAG 'level 0' DATABASE ;
SQL 'alter system archive log current' ;
BACKUP FILESPERSET 3 ARCHIVELOG ALL DELETE INPUT;
RELEASE CHANNEL CH1;
RELEASE CHANNEL CH2;
}
ALLOCATE CHANNEL FOR MAINTENANCE DEVICE TYPE DISK;
CROSSCHECK BACKUPSET;
DELETE NOPROMPT EXPIRED BACKUP;
DELETE NOPROMPT OBSOLETE ;
shell脚本:
#!/bin/bash
RUN_USER="oracle"
rq=`date "+%Y%m%d"`
fname="*$rq*"
if [ "$LOGNAME" != "$RUN_USER" ]; then
echo "Please run this script as $RUN_USER " >> /u02/rmback/log/$rq.log
exit 1
fi
cd $HOME
. .bash_profile
weekname=`date +%A`
case "$weekname" in
Sunday)
echo -n "Today is $weekname,Back oracle Level 0" >> /u02/rmback/log/oracle.log
date "+ %Y-%m-%d %T Start to backup DateBase" >> /u02/rmback/log/oracle.log
rman cmdfile=/u02/rmback/scripts/rman_level0.rcv msglog=/u02/rmback/log/$rq.log
date "+ %Y-%m-%d %T RMAN BACKUP finished " >> /u02/rmback/log/oracle.log
;;
Wednesday)
echo -n "Today is $weekname,Back oracle Level 1" >> /u02/rmback/log/oracle.log
date "+ %Y-%m-%d %T Start to backup DateBase" >> /u02/rmback/log/oracle.log
rman cmdfile=/u02/rmback/scripts/rman_level1.rcv msglog=/u02/rmback/log/$rq.log
date "+ %Y-%m-%d %T RMAN BACKUP finished " >> /u02/rmback/log/oracle.log
;;
*)
echo -n "Today is $weekname,Back oracle Level 2" >> /u02/rmback/log/oracle.log
date "+ %Y-%m-%d %T Start to backup DateBase" >> /u02/rmback/log/oracle.log
rman cmdfile=/u02/rmback/scripts/rman_level2.rcv msglog=/u02/rmback/log/$rq.log
date "+ %Y-%m-%d %T RMAN BACKUP finished " >> /u02/rmback/log/oracle.log
;;
esac
crontab -l
01 01 * * * (/u02/rmback/scripts/rman_bak.sh > /u02/rmback/log/oracle 2>&1)
######################################################################
一个TB级数据库的备份时间及备份记录
run{
allocate channel d1 type disk maxpiecesize=50G;
allocate channel d2 type disk maxpiecesize=50G;
backup full database filesperset 10 include current controlfile format '/backup/fullbak_%d_%T_%s_%p'
plus archivelog format '/backup/archbak_%d_%T_%s' delete all input;
release channel d1;
release channel d2;
}
source:http://www.eygle.com/archives/2009/09/tb_backup_time_record.html