码迷,mamicode.com
首页 > 其他好文 > 详细

RMAN备份脚本

时间:2017-07-13 10:51:52      阅读:192      评论:0      收藏:0      [点我收藏+]

标签:conf   let   1.2   清理   ann   log   hba   rman备份   system   

#!/bin/sh
#------------------------------------------------------------------------------------------------------------
#Environment variable setting
#------------------------------------------------------------------------------------------------------------
. /home/oracle/.bash_profile

export ORACLE_BASE=/home/oracle/app
export ORACLE_HOME=$ORACLE_BASE/oracle/product/11.2.0/dbhome_1
export ORACLE_SID=yyhorcl
export NLS_LANG="SIMPLIFIED CHINESE_CHINA.ZHS16GBK"

PATH=.:${PATH}:$HOME/bin:$ORACLE_HOME/bin
PATH=${PATH}:/usr/bin:/bin:/usr/bin/X11:/usr/local/bin
PATH=${PATH}:/u01/app/common/oracle/bin
export PATH


SH_HOME=/home/oracle/rman
export SH_HOME


DATE=`date +"%Y%m%d"`
week=`date +"%w"`
rmanerror=$SH_HOME/log/rmanerror.log

 

#-----------------------------------------------------------------------
#Confirm whether the oracle IS runing
#-----------------------------------------------------------------------
sqlplus -s "/as sysdba"<<EOF
whenever sqlerror exit 1
whenever oserror exit 1
SELECT sysdate FROM dual;
exit
EOF

if [ $? -gt 0 ]; then
exit
fi

#-----------------------------------------------------------------------
#Begin TO delete archivelog
#-----------------------------------------------------------------------
#$ORACLE_HOME/bin/rman <<EOF
#connect target /
#crosscheck archivelog all;
#delete noprompt expired archivelog all;
#delete noprompt archivelog until time ‘sysdate-7‘;
#exit;
#EOF

if [ $week = "0" ] || [ $week = "3" ]; then
rman target / @$SH_HOME/fullinc0.rcv log=$SH_HOME/log/rmanfullback`date +"%Y-%m-%d"`.log
else
rman target / @$SH_HOME/del_arc.rcv log=$SH_HOME/log/rmanarchback`date +"%Y-%m-%d"`.log
fi

 

 

其中:

[oracle@localhost.localdomain:/home/oracle/rman]$more del_arc.rcv
run{
crosscheck archivelog all;
delete noprompt expired archivelog all;
delete noprompt archivelog until time ‘sysdate-7‘;
}

#用于清理过期归档日志

[oracle@localhost.localdomain:/home/oracle/rman]$more fullinc0.rcv
delete noprompt obsolete;
run{
allocate channel c1 type disk;
backup
incremental level 0
format "/home/oracle/app/rmanbak/full_inc0_%u_%T"
tag full_inc0
database include current controlfile;
sql ‘alter system archive log current‘;
backup archivelog all format ‘/home/oracle/app/rmanbak/arc_%s_%p.bk_2‘ delete all input;
release channel c1;
}

#执行零级全备份

RMAN备份脚本

标签:conf   let   1.2   清理   ann   log   hba   rman备份   system   

原文地址:http://www.cnblogs.com/palmxin/p/7158619.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!