在做Oracle全备份脚本修改时,领导提的要求
1、如果已经有全备份了,则自动退出不要报错
2、如果有日志备份了,则继续等待直到日志备份结束才进行全备份
第一条的理由就不说了
为什么要提第二条理由呢,是因为如果全备份开始的时候日志备份依然在进行,则这个全备份的数据是不完全的(必须要加上一开始的那个日志备份备走的数据);
脚本中添加如下的判断语句
- DT=`/usr/bin/date +%Y%m%d%H%M`
-
-
RMAN_LOG_FILE=${0}_${DT}.out
-
echo > $RMAN_LOG_FILE
-
chmod 666 $RMAN_LOG_FILE
-
echo Script $0 >> $RMAN_LOG_FILE
-
echo ==== started on `date` ==== >> $RMAN_LOG_FILE
-
echo >> $RMAN_LOG_FILE
-
-
ORACLE_HOME=/u01/oracle/product/db10gr2
-
export ORACLE_HOME
-
-
ORACLE_SID=idsauto
-
export ORACLE_SID
-
-
ORACLE_USER=oracle
-
-
# Check if there any full backup or archivelog is running
-
PROGNAME=$0
-
MYPID=$$
-
RUNNING_CHECK_NAME="$PROGNAME"
-
ARCHIVELOG_CHECK_NAME="/usr/openv/scripts/${ORACLE_SID}_archivelog_backup.sh"
#判断是否有其他的全备份
-
OTHERRUNS=`/usr/bin/ps -ef|/usr/bin/egrep "$RUNNING_CHECK_NAME"|grep -v $MYPID|grep -vc grep`
-
echo "check running" >>$RMAN_LOG_FILE
-
if [ $OTHERRUNS -gt 0 ]
-
then
-
echo "FULL BACKUP IS RUNNING, OTHER RUNS is $OTHERRUNS, Exit" >>$RMAN_LOG_FILE
-
/usr/bin/ps -ef|/usr/bin/egrep "$RUNNING_CHECK_NAME|$FULLBACKUP_CHECK_NAME"|grep -v $MYPID|grep -v grep >>$RMAN_LOG_FILE
-
exit 0
-
fi
- #判断是否有日志备份
-
ARCHIVELOGRUNS=`/usr/bin/ps -ef|/usr/bin/egrep "$ARCHIVELOG_CHECK_NAME"|grep -vc grep`
-
echo "ARCHIVELOGRUNS $ARCHIVELOGRUNS" >>$RMAN_LOG_FILE
-
while [ $ARCHIVELOGRUNS -gt 0 ]
-
do
-
echo "ARCHIVELOG IS RUNNING, WAIT 300 Seconds" >>$RMAN_LOG_FILE
-
sleep 300
-
ARCHIVELOGRUNS=`/usr/bin/ps -ef|/usr/bin/egrep "$ARCHIVELOG_CHECK_NAME"|grep -vc grep`
-
echo "ARCHIVELOGRUNS $ARCHIVELOGRUNS" >>$RMAN_LOG_FILE
-
done
阅读(1708) | 评论(0) | 转发(0) |