rman_backup_crontab
xianghui
175次下载
1625次浏览
2019-08-08
4

脚本内容

每周日凌晨3点全备,其他时间每半小时备份一次归档,备份文件保留两周 [oracle@DB01 backup]$ crontab -l 0 3 * * 0 /home/oracle/backup/full_backup.sh 0,30 */1 * * * /home/oracle/backup/arch_backup.sh 14,30 */24 * * * find /oradata/rman_backup -mtime +14 |xargs rm -rf [oracle@DB01 backup]$ cat /home/oracle/backup/arch_backup.sh #!/bin/sh #Full Archive Backup Script export ORACLE_HOME=/oracle/app/oracle/product/11.2.0/db2 export ORACLE_SID=db01 export DBNAME=db export PATH=$ORACLE_HOME/bin:$PATH year=`date "+%Y"` month=`date "+%m"` day=`date "+%d"` hour=`date "+%H"` min=`date "+%M"` sec=`date "+%S"` bakdate=$year$month$day baktime=$hour$min$sec BACKUP_DIR=/oradata/rman_backup/$bakdate SCRIPT_DIR=/home/oracle/backup CMDFILE=$SCRIPT_DIR/arch_backup.rman LOGFILE=$SCRIPT_DIR/log/arch/${bakdate}_${baktime}_arch.log mkdir $BACKUP_DIR cd /home/oracle >$CMDFILE cat <<EOF >>$CMDFILE run{ allocate channel ch1 device type disk; allocate channel ch2 device type disk; allocate channel ch3 device type disk; allocate channel ch4 device type disk; allocate channel ch5 device type disk; allocate channel ch6 device type disk; sql 'alter system checkpoint'; sql 'alter system switch logfile'; sql 'alter system archive log current' ; CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 14 DAYS; CONFIGURE SNAPSHOT CONTROLFILE NAME TO '${BACKUP_DIR}/${DBNAME}_ctl_orcl1.f'; backup as compressed backupset filesperset 10 format '${BACKUP_DIR}/${DBNAME}_arch_%s_%p_%T' archivelog all not backed up 2 times ; delete noprompt ARCHIVELOG UNTIL TIME 'SYSDATE-6'; backup format '${BACKUP_DIR}/${DBNAME}_ctl_%U.%T' current controlfile; release channel ch1; release channel ch2; release channel ch3; release channel ch4; release channel ch5; release channel ch6; } EOF rman target / log=${LOGFILE} < $CMDFILE [oracle@DB01 backup]$ cat /home/oracle/backup/full_backup.sh #!/bin/sh #Full Database Backup Script export ORACLE_HOME=/oracle/app/oracle/product/11.2.0/db2 export ORACLE_SID=db01 export DBNAME=db export PATH=$ORACLE_HOME/bin:$PATH year=`date "+%Y"` month=`date "+%m"` day=`date "+%d"` hour=`date "+%H"` min=`date "+%M"` sec=`date "+%S"` bakdate=$year$month$day baktime=$hour$min$sec BACKUP_DIR=/oradata/rman_backup/$bakdate SCRIPT_DIR=/home/oracle/backup CMDFILE=$SCRIPT_DIR/full_backup.rman LOGFILE=$SCRIPT_DIR/log/${bakdate}_${baktime}_full.log mkdir $BACKUP_DIR cd /home/oracle >$CMDFILE cat <<EOF >>$CMDFILE run{ allocate channel ch1 device type disk; allocate channel ch2 device type disk; allocate channel ch3 device type disk; allocate channel ch4 device type disk; allocate channel ch5 device type disk; allocate channel ch6 device type disk; sql 'alter system checkpoint'; sql 'alter system switch logfile'; sql 'alter system archive log current' ; CONFIGURE SNAPSHOT CONTROLFILE NAME TO '${BACKUP_DIR}/${DBNAME}_ctl_orcl1.f'; crosscheck backup; delete noprompt expired backup; backup as compressed backupset full database filesperset 10 format '${BACKUP_DIR}/${DBNAME}_full_%u_%p_%T' plus archivelog format '${BACKUP_DIR}/${DBNAME}_plus_arch_%u_%p_%T'; backup format '${BACKUP_DIR}/${DBNAME}_ctl_%U.%T' current controlfile; backup spfile format '${BACKUP_DIR}/${DBNAME}_spfile_%U.%T'; release channel ch1; release channel ch2; release channel ch3; release channel ch4; release channel ch5; release channel ch6; } EOF rman target / log=${LOGFILE} < $CMDFILE [oracle@OADB01 backup]$

评论

贡献排行榜