oracle11g Rman 備份指令碼
1、Rman備份指令碼
備份策略:周天0級備份,其他時候1級備份
- ########################################################################
- ## kfc_incremental_hot_database_backup.sh ##
- ## created by NBU TEMP ##
- ## 2012-3-8 ##
- #########################################################################
- #!/bin/ksh
- export LANG=en_US
- BACKUP_DATE=`date +%d`
- RMAN_LOG_FILE=/home/oracle/backup/log/backupinfo.out
- TODAY=`date`
- USER=`id|cut -d "(" -f2|cut -d ")" -f1`
- echo "-----------------$TODAY-------------------">$RMAN_LOG_FILE
- ORACLE_HOME=/opt/oracle/product/11.2.0/dbhome_1
- export ORACLE_HOME
- RMAN=$ORACLE_HOME/bin/rman
- export RMAN
- ORACLE_SID=kfsjora
- export ORACLE_SID
- ORACLE_USER=oracle
- export ORACLE_USER
- echo "ORACLE_SID: $ORACLE_SID">>$RMAN_LOG_FILE
- echo "ORACLE_HOME:$ORACLE_HOME">>$RMAN_LOG_FILE
- echo "ORACLE_USER:$ORACLE_USER">>$RMAN_LOG_FILE
- echo "==========================================">>$RMAN_LOG_FILE
- echo "BACKUP DATABASE BEGIN......">>$RMAN_LOG_FILE
- echo " ">>$RMAN_LOG_FILE
- #touch $RMAN_LOG_FILE
- chmod 666 $RMAN_LOG_FILE
- WEEK_DAILY=`date +%a`
- case "$WEEK_DAILY" in
- "Mon")
- BAK_LEVEL=1
- ;;
- "Tue")
- BAK_LEVEL=1
- ;;
- "Wed")
- BAK_LEVEL=1
- ;;
- "Thu")
- BAK_LEVEL=1
- ;;
- "Fri")
- BAK_LEVEL=1
- ;;
- "Sat")
- BAK_LEVEL=1
- ;;
- "Sun")
- BAK_LEVEL=0
- ;;
- "*")
- BAK_LEVEL=error
- esac
- export BAK_LEVEL=$BAK_LEVEL
- echo "Today is : $WEEK_DAILY incremental level= $BAK_LEVEL">>$RMAN_LOG_FILE
- RUN_STR="
- BAK_LEVEL=$BAK_LEVEL
- export BAK_LEVEL
- ORACLE_HOME=$ORACLE_HOME
- export ORACLE_HOME
- ORACLE_SID=$ORACLE_SID
- export ORACLE_SID
-
$RMAN TARGET sys/qhyc_pass CATALOG kfcrman/kfcrman@kfcrman msglog $RMAN_LOG_FILE append <
- run
- {
- allocate channel c1 type disk;
- allocate channel c2 type disk;
- backup incremental level= $BAK_LEVEL skip inaccessible filesperset 5 Database format='/opt/kfsjora_backup/orcl_lev"$BAK_LEVEL"_%U_%T' tag='orcl_lev"$BAK_LEVEL"' ;
- sql 'alter system archive log current';
- backup archivelog all tag='arc_bak' format='/opt/kfsjora_backup/arch_%U_%T' skip inaccessible filesperset 5 not backed up 1 times delete input;
- backup current controlfile tag='bak_ctlfile' format='/opt/kfsjora_backup/ctl_file_%U_%T';
- backup spfile tag='spfile' format='/opt/kfsjora_backup/ORCL_spfile_%U_%T';
- release channel c2;
- release channel c1;
- }
- report obsolete;
- delete noprompt obsolete;
- crosscheck backup;
- delete noprompt expired backup;
- list backup summary;
- resync catalog;
- EOF
- "
- # Initiate the command string
- if [ "$CUSER" = "root" ]
- then
- echo "Root Command String: $RUN_STR" >> $RMAN_LOG_FILE
- su - $ORACLE_USER -c "$RUN_STR" >> $RMAN_LOG_FILE
- RSTAT=$?
- else
- echo "User Command String: $RUN_STR" >> $RMAN_LOG_FILE
- /bin/sh -c "$RUN_STR" >> $RMAN_LOG_FILE
- RSTAT=$?
- fi
- # ---------------------------------------------------------------------------
- # Log the completion of this script.
- # ---------------------------------------------------------------------------
- if [ "$RSTAT" = "0" ]
- then
- LOGMSG="ended successfully"
- else
- LOGMSG="ended in error"
- fi
- echo >> $RMAN_LOG_FILE
- echo Script $0 >> $RMAN_LOG_FILE
- echo ==== $LOGMSG on `date` ==== >> $RMAN_LOG_FILE
- echo >> $RMAN_LOG_FILE
- /bin/mailx -s "RMAN Backup SID " oracle@kfc.localdomain
- exit $RSTAT
2、刪除歸檔備份和oracle trc等檔案的指令碼
- #!/bin/ksh
- # ##################################################################
- #
- # delete_archvivelog_backup_and_trc_trm_file.sh
- #
- #
- # ##################################################################
- PATH=/usr/bin:/usr/ucb:/etc:.:/usr/X/bin:/bin
- export PATH
- #find /opt/kfsjora_backup -mtime +15 -name "arch_*" -exec rm "{} /;"
- find /opt/kfsjora_backup -mtime +15 -name "arch_*" -exec rm {} \;
- find /opt/oracle/admin/kfsjora/adump/ -mtime +15 -name "*.aud" -exec rm {} \;
- find /opt/oracle/diag/rdbms/kfsjora/kfsjora/cdump/ -mtime +15 -name "*" -exec rm -fr {} \;
- find /opt/oracle/diag/rdbms/kfsjora/kfsjora/trace/ -mtime +15 -name "*.tr?" -exec rm {} \;
3、匯出Rman catalog資料 的指令碼
- #!/bin/ksh
- # ##################################################################
- #
- # exprman.sh
- #
- #
- # ##################################################################
- ORACLE_HOME=$ORACLE_BASE/product/11.2.0/dbhome_1; export ORACLE_HOME
- PATH=/usr/bin:/usr/ucb:/etc:.:/usr/X/bin:/bin:$ORACLE_HOME/bin:/usr/sbin
- export PATH
- EXP_BASE=/home/oracle/backup/exprman
- export EXP_BASE
- NLS_LANG=AMERICAN_AMERICA.ZHS16GBK
- export NLS_LANG
- if [ -s "$EXP_BASE/kfcrman_new.dmp" ];then
- rm $EXP_BASE/kfcrman_old.dmp
- mv $EXP_BASE/kfcrman_new.dmp $EXP_BASE/kfcrman_old.dmp
- fi
- exp kfcrman/kfcrman@kfcrman tablespaces=KFC3850 file=$EXP_BASE/kfcrman_new.dmp >>$EXP_BASE/../log/expkfcrman.log 2>&1
4、設定 crontab 定期執行上述指令碼
$crontab -e
加入如下內容
- 00 1 * * * /home/oracle/backup/script/kfc_incremental_hot_database_backup.sh &
- 00 2 * * * /home/oracle/backup/script/delete_archvivelog_backup_and_trc_trm_file.sh >/home/oracle/backup/log/log_delete_archvivelog_backup_and_trc_trm_file.log 2>&1 &
-
00 5 1 * * /home/oracle/backup/script/expkfcrman.sh
source:http://blog.csdn.net/upcorange/article/details/7335990
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/27036311/viewspace-1629414/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- rman 備份指令碼指令碼
- rman備份指令碼指令碼
- rman備份和增量備份指令碼指令碼
- rman 全備份指令碼指令碼
- rman增量備份指令碼指令碼
- windows rman備份指令碼Windows指令碼
- RMAN常用備份指令碼指令碼
- oracle RMAN備份指令碼Oracle指令碼
- [Oracle] rman備份指令碼(2)Oracle指令碼
- 使用rman備份的指令碼指令碼
- oracle rman備份指令碼收集Oracle指令碼
- Windows下RMAN備份指令碼Windows指令碼
- RMAN全庫備份指令碼指令碼
- RMAN備份Shel指令碼示例指令碼
- Rman備份的shell指令碼指令碼
- 分享Oracle Rman的備份指令碼Oracle指令碼
- oracle rman 定時備份指令碼Oracle指令碼
- RMAN定時全備份指令碼指令碼
- 轉貼:RMAN備份指令碼(Unix)指令碼
- [Oracle] rman備份的指令碼(1)Oracle指令碼
- rman 自動備份指令碼-windows指令碼Windows
- rman備份的shell指令碼(例子)指令碼
- ORACLE RMAN備份的指令碼配置Oracle指令碼
- RAC模式下的備份策略以及RMAN備份指令碼模式指令碼
- rman的備份檢視的指令碼指令碼
- linux 下RMAN備份shell指令碼Linux指令碼
- RMAN備份歸檔日誌指令碼指令碼
- windows下rman自動備份指令碼Windows指令碼
- RMAN備份恢復測試指令碼指令碼
- 【RMAN】RMAN備份恢復3 RMAN增量備份指令碼與crontab計劃任務指令碼
- RAC模式下的備份策略以及RMAN備份指令碼(轉)模式指令碼
- RAC模式下的備份策略以及RMAN備份指令碼(ZF)模式指令碼
- oracle資料庫使用rman備份指令碼Oracle資料庫指令碼
- rman備份指令碼 傳送郵件通知指令碼
- Oracle生產環境RMAN備份指令碼Oracle指令碼
- 一個完整的RMAN備份指令碼(轉)指令碼
- TSM+RMAN 自動備份指令碼 on aix指令碼AI
- [Rman]Oracle Rman增量備份Level012指令碼Oracle指令碼