rman备份脚本shell版
1、数据库全备到硬盘
10年积累的成都网站制作、网站建设经验,可以快速应对客户对网站的新想法和需求。提供各种问题对应的解决方案。让选择我们的客户得到更好、更有力的网络服务。我虽然不认识你,你也不认识我。但先网站策划后付款的网站建设流程,更有友谊免费网站建设让你可以放心的选择与我们合作。
[oracle@centos7 scripts]$ cat rman_backup.sh source /home/oracle/.bash_profile rman target / log=/home/oracle/backup/backupall_rman.log<2、增量备份脚本
0级增量
[oracle@centos7 scripts]$ cat rman_backup_level0.sh source /home/oracle/.bash_profile rman target / log=/home/oracle/backup/backupall_rman.log<1级增量
[oracle@centos7 scripts]$ cat rman_backup_level1.sh source /home/oracle/.bash_profile rman target / log=/home/oracle/backup/backupall_rman.log<注意:1级备份需要在0级备份的基础上执行。
3、支持全备和增量备份
[oracle@centos7 scripts]$ cat db_back_rman.sh ##=========================================================== ## db_bak_rman.sh ## created by Robinson ## 2017/12/15 ## usage: db_bak_rman.sh <$ORACLE_SID> <$BACKUP_LEVEL> ## BACKUP_LEVEL: ## F: full backup ## 0: level 0 ## 1: level 1 ##============================================================ #!/bin/bash # User specific environment and startup programs if [ -f ~/.bash_profile ]; then . ~/.bash_profile fi ORACLE_SID=${1}; export ORACLE_SID RMAN_LEVEL=${2}; export RMAN_LEVEL TIMESTAMP=`date +%Y%m%d%H%M`; export TIMESTAMP DATE=`date +%Y%m%d`; export DATE RMAN_DIR=/u02/database/${ORACLE_SID}/backup/rman; export RMAN_DIR RMAN_DATA=${RMAN_DIR}/${DATE}; export RMAN_DATA #RMAN_LOG=$RMAN_DATA/log; export RMAN_LOG RMAN_LOG=/u02/database/${ORACLE_SID}/backup/rman/log export RMAN_LOG # Check rman level #====================================================================== if [ "$RMAN_LEVEL" == "F" ]; then unset INCR_LVL BACKUP_TYPE=full else INCR_LVL="INCREMENTAL LEVEL ${RMAN_LEVEL}" BACKUP_TYPE=lev${RMAN_LEVEL} fi RMAN_FILE=${RMAN_DATA}/${ORACLE_SID}_${BACKUP_TYPE}_${TIMESTAMP}; export RMAN_FILE SSH_LOG=${RMAN_LOG}/${ORACLE_SID}_${BACKUP_TYPE}_${TIMESTAMP}.log; export SSH_LOG MAXPIECESIZE=4G; export MAXPIECESIZE #Check RMAN Backup Path #========================================================================= if ! test -d ${RMAN_DATA} then mkdir -p ${RMAN_DATA} fi echo "---------------------------------" >>${SSH_LOG} echo " " >>${SSH_LOG} echo "Rman Begin to Working ........." >>${SSH_LOG} echo "Begin time at:" `date` --`date +%Y%m%d%H%M` >>${SSH_LOG} #Startup rman to backup #============================================================================= $ORACLE_HOME/bin/rman log=${RMAN_FILE}.log <>${SSH_LOG} echo "Rman Stop working @ time:"`date` `date +%Y%m%d%H%M` >>${SSH_LOG} echo >>${SSH_LOG} echo "------------------------" >>${SSH_LOG} echo "------ Disk Space ------" >>${SSH_LOG} df -h >>${SSH_LOG} echo >>${SSH_LOG} if [ $RC -ne "0" ]; then echo "------ error ------" >>${SSH_LOG} else echo "------ no error found during RMAN backup peroid------" >>${SSH_LOG} rm -rf ${RMAN_FILE}.log fi #Remove old backup than 3 days #============================================================================ RMDIR=${RMAN_DIR}/`/bin/date +%Y%m%d -d "3 days ago"`; export RMDIR echo >>${SSH_LOG} echo -e "------Remove old backup than 3 days ------\n" >>${SSH_LOG} if test -d ${RMDIR} then rm -rf ${RMDIR} RC=$? fi echo >>${SSH_LOG} if [ $RC -ne "0" ]; then echo -e "------ Remove old backup exception------ \n" >>${SSH_LOG} else echo -e "------ no error found during remove old backup set peroid------ \n" >>${SSH_LOG} fi exit
文章名称:rman备份脚本shell版
文章来源:http://myzitong.com/article/jjeehj.html