ITPub博客

首页 > Linux操作系统 > Linux操作系统 > RMAN的备份脚本

RMAN的备份脚本

原创 Linux操作系统 作者:十窝羊 时间:2013-11-07 18:42:00 0 删除 编辑
查看执行脚本rman.sh

点击(此处)折叠或打开

  1. #!/bin/bash
  2. SH_HOME=/backup/rman
  3. export SHELL_HOME
  4. ORACLE_SID=orcl
  5. export ORACLE_SID
  6. DATE=`date +\"%Y%m%d%H%M\"`
  7. WEEK=`date +%w`

  8. if [ ! -d \"$SH_HOME/log\" ] ; then
  9.         mkdir -p $SH_HOME/log
  10. fi

  11. RMAN_LOG=${SH_HOME}/log/RMAN_BACKUP_${DATE}.log

  12. if [ -f \"$RMAN_LOG\" ] ; then
  13.         rm -rf $RMAN_LOG
  14.         touch $RMAN_LOG
  15.    else
  16.         touch $RMAN_LOG
  17. fi


  18. ps -ef|grep \"dbw0_$ORACLE_SID\" |grep -v grep

  19. if [ $? -eq 0 ] ; then
  20.         if [ $WEEK -eq 0 ] ; then
  21.                 echo \"BACKUP TYPE IS INCREMENTAL LEVEL=0 \" >> $RMAN_LOG
  22.                 echo ____________________________________ >> $RMAN_LOG
  23.                 echo \"{\" >> $RMAN_LOG
  24.                 rman target / @$SH_HOME/backuplevel0.sql log=$RMAN_LOG
  25.                 echo \"}\" >> $RMAN_LOG
  26.             else
  27.                         echo \"BACKUP TYPE IS INCREMENTAL LEVEL=1 \" >> $RMAN_LOG
  28.                         echo ____________________________________ >> $RMAN_LOG
  29.                         echo \"{\" >> $RMAN_LOG
  30.                         rman target / @$SH_HOME/backuplevel1.sql log=$RMAN_LOG
  31.                         echo \"}\" >> $RMAN_LOG
  32.         fi
  33. fi

backuplevel0.sh:

点击(此处)折叠或打开

  1. run{
  2. CROSSCHECK ARCHIVELOG ALL;
  3. CROSSCHECK BACKUP;
  4. BACKUP INCREMENTAL LEVEL=0 TAG \'LEVEL0\' database
  5.         INCLUDE CURRENT CONTROLFILE
  6.         FORMAT \'/backup/rman/lv0_%d_%T_%s\'
  7.         PLUS ARCHIVELOG
  8.         FORMAT \'/backup/rman/archive_log_%d_%T_%s\' DELETE ALL INPUT;
  9. DELETE NOPROMPT OBSOLETE;
  10. }

backuplevel1:

点击(此处)折叠或打开

  1. run{
  2. CROSSCHECK ARCHIVELOG ALL;
  3. CROSSCHECK BACKUP;
  4. DELETE NOPROMPT OBSOLETE;
  5. BACKUP INCREMENTAL LEVEL=1 TAG \'LEVEL1\' DATABASE
  6.         INCLUDE CURRENT CONTROLFILE
  7.         FORMAT \'/backup/rman/lv1_%d_%T_%s\';
  8. sql \'alter system archive log current\';
  9. DELETE NOPROMPT OBSOLETE;
  10. BACKUP ARCHIVELOG ALL
  11.         FORMAT \'/backup/rman/archive_log_%d_%T_%s\'
  12.         DELETE ALL INPUT;
  13. }



来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/24871431/viewspace-776044/,如需转载,请注明出处,否则将追究法律责任。

下一篇: 没有了~
请登录后发表评论 登录
全部评论

注册时间:2013-11-06

  • 博文量
    4
  • 访问量
    58198