本篇内容介绍了“linux下oracle rman备份脚本代码”的有关知识,在实际案例的操作过程中,不少人都会遇到这样的困境,接下来就让小编带领大家学习一下如何处理这些情况吧!希望大家仔细阅读,能够学有所成!
#!/bin/bash
# author:xjf
# date:20190828
# desc:backup database
# set environment variable
export ORACLE_SID=orcl
export ORACLE_BASE=/home/soft/oracle/app
export ORACLE_HOME=$ORACLE_BASE/orcl
export ORACLE_UNQNAME=orcl
export PATH=$PATH:$ORACLE_HOME/bin
#log file
RMAN_LOG=/home/oracle/shell/logs/rman/$(date +%Y%m%d%H%M);
TEMP_LOG=/home/oracle/bak/rman.log;
#week
WEEK_DAY=$(date +%w)
if [ $WEEK_DAY -eq 7 ]; then
INCR_LVL="INCREMENTAL LEVEL=0"
else
INCR_LVL="INCREMENTAL LEVEL=1"
fi;
echo "---------------------------------" >>${RMAN_LOG}
echo "Rman Begin time at:"$(date +%Y%m%d%H%M) >>${RMAN_LOG}
echo "Rman level: ${INCR_LVL}" >>${RMAN_LOG}
#execute rman
$ORACLE_HOME/bin/rman log=${TEMP_LOG}<<EOF
connect target /
RUN {
CONFIGURE DEVICE TYPE DISK PARALLELISM 8;
CONFIGURE RETENTION POLICY TO REDUNDANCY 2;
CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 7 DAYS;
CONFIGURE BACKUP OPTIMIZATION ON;
CONFIGURE CONTROLFILE AUTOBACKUP ON;
CROSSCHECK BACKUP;
DELETE NOPROMPT EXPIRED BACKUP;
CROSSCHECK ARCHIVELOG ALL;
DELETE NOPROMPT EXPIRED ARCHIVELOG ALL;
REPORT OBSOLETE;
DELETE NOPROMPT OBSOLETE;
#BACKUP ${INCR_LVL} DATABASE PLUS ARCHIVELOG DELETE INPUT;
}
EXIT;
EOF
#log
cat ${TEMP_LOG}>>${RMAN_LOG}
echo "Rman Stop working at time:"$(date +%Y%m%d%H%M)>>${RMAN_LOG}
exit
“linux下oracle rman备份脚本代码”的内容就介绍到这里了,感谢大家的阅读。如果想了解更多行业相关的知识可以关注亿速云网站,小编将为大家输出更多高质量的实用文章!