Oracle rman 备份二

简介: ---------------------------------------------------------------------------------------------------------------------------------------------------3...

---------------------------------------------------------------------------------------------------------------------------------------------------

30 8,9,10,11,12,13,14,15,16,17,18 * * * nohup /backup/script/backup_l0_l1.sh >/dev/null 2>&1 &

0 19 * * * nohup /backup/script/backup_l0_l1.sh >/dev/null 2>&1 &

vi backup_l0_l1.sh 

#!/bin/bash

export recore_bk_time=$(date +%y%m%d)

export week=$(date +%w)

export ORACLE_BASE=/u01/app/oracle

export ORACLE_HOME=/u01/app/oracle/product/11.2.0/db_1

export ORACLE_SID=ORCL

export PATH=$ORACLE_HOME/bin:$PATH

export TZ=Asia/Shanghai

export ORACLE_TERM=xterm

export NLS_DATE_FORMAT='YYYY-MM-DD HH24:MI:SS'

export NLS_LANG=AMERICAN_AMERICA.ZHS16GBK;

export BACKUP_HOME=/backup/data

export RMAN_DEST=/backup/data/$(date +%Y)_$(date +%W)week_rman/

export LOGFILE=$BACKUP_HOME/logs/${ORACLE_SID}_rman_$recore_bk_time.log


if [ ! -d "$RMAN_DEST" ]; then

  mkdir "$RMAN_DEST"

fi

#Enable incremental backup except monday


case $week in

        1)

        LEVEL=0 && printf "[$ORACLE_SID]:$(date):rman backup begin with incremental level $LEVEL\n" >>$LOGFILE

;;

        *)

        LEVEL=1 && printf "[$ORACLE_SID]:$(date):rman backup begin with incremental level $LEVEL\n" >>$LOGFILE

;;

esac


export time1=$(date +%s)


rman target / log=$LOGFILE append <<EOF

run{

        backup as compressed backupset device type disk incremental level=$LEVEL format '${RMAN_DEST}/db_full_%d_%s_%p_%t' database  tag='db_l_$LEVEL';

        sql 'alter system archive log current';

        backup as compressed backupset device type disk archivelog from time 'sysdate-14' until time 'sysdate' format '${RMAN_DEST}/arc_%d_%s_%p_%t' delete input tag='arclog';

        delete noprompt obsolete recovery window of 10 days;

        backup current controlfile format '${RMAN_DEST}/ctl_%d_%s_%p_%t' tag='ctl';

}

exit;

EOF


time2=$(date +%s)

runtime1=$(((time2-time1)/60))

runtime2=$(((time2-time1)%60))

echo "Total time for this backup "$runtime1"Min "$runtime2"Sec;"  >> $LOGFILE

if [ $? -eq 0 ];then

        printf "[$ORACLE_SID]:$(date):rman backup successfully with incremental level $LEVEL\n" >>$LOGFILE

else

        printf "[$ORACLE_SID]:$(date):rman backup failed with incremental level $LEVEL,please check rman log ${ORACLE_SID}_rman.log\n" >>$LOGFILE

fi

目录
相关文章
|
4月前
|
Oracle 安全 关系型数据库
|
4月前
|
存储 Oracle 关系型数据库
|
4月前
|
Oracle 关系型数据库 数据库
|
4月前
|
存储 监控 Oracle
关系型数据库Oracle备份策略建议
【7月更文挑战第21天】
68 6
|
4月前
|
存储 Oracle 关系型数据库
|
4月前
|
存储 Oracle 关系型数据库
关系型数据库Oracle运行RMAN脚本
【7月更文挑战第23天】
50 4
|
4月前
|
SQL Oracle 关系型数据库
关系型数据库Oracle设置 RMAN 环境:
【7月更文挑战第25天】
70 2
|
4月前
|
监控 Oracle 算法
|
4月前
|
SQL Oracle 关系型数据库
关系型数据库Oracle结束 RMAN 会话:
【7月更文挑战第25天】
86 1
|
4月前
|
Oracle 关系型数据库 数据库
关系型数据库Oracle编写RMAN脚本
【7月更文挑战第23天】
43 2