当前位置:  数据库>oracle

RMAN自动备份脚本一例

    来源: 互联网  发布时间:2017-04-24

    本文导语: 1、Oracle定时任务: crontab -e * * * * * /home/oracle/workspace/scripts/bk_main.sh>> /home/oracle/workspace/log/bk_err.log 2>&1 2、主控制程序 /home/oracle/workspace/scripts/bk_main.sh #!/bin/bash   dat=`date +'%M'`   if (($dat==0)) then  /home/oracle/workspace/s...

1、Oracle定时任务

crontab -e

* * * * * /home/oracle/workspace/scripts/bk_main.sh>> /home/oracle/workspace/log/bk_err.log 2>&1

2、主控制程序

/home/oracle/workspace/scripts/bk_main.sh

#!/bin/bash

 

dat=`date +'%M'`

 

if (($dat==0))

then

 /home/oracle/workspace/scripts/bk_.sh 0

elif (($dat%50==0))

then

 /home/oracle/workspace/scripts/bk_.sh 2

elif (($dat%40==0))

then

 /home/oracle/workspace/scripts/bk_.sh 2

elif (($dat%30==0))

then

 /home/oracle/workspace/scripts/bk_.sh 1

elif (($dat%20==0))

then

 /home/oracle/workspace/scripts/bk_.sh 2

elif (($dat%10==0))

then

 /home/oracle/workspace/scripts/bk_.sh 2

fi

3、详细备份脚本
说明:`date +'%Y%m%d%k%M' | awk '{print $1$2}'` 为当前时间的yyyymmddhh24mi格式

/home/oracle/workspace/scripts/bk_.sh

#!/bin/bash

#This is a import statement.

PATH=$PATH:$HOME/bin

 

export PATH

export ORACLE_SID=dex

export ORACLE_BASE=/u01/apps/oracle

export ORACLE_HOME=$ORACLE_BASE/product/11gr2/db_1

export PATH=$ORACLE_HOME/bin:$PATH

#use awk to cut the space char

timst=`date +'%Y%m%d%k%M' | awk '{print $1$2}'`

#Use for debug

#echo $timst

#Create a directory like 201112140112

mkdir /u01/backup/DEX/backups/$timst

#Rman backup scripts

rman target sys/xiaojun@dex log=/home/oracle/workspace/log/rmanlog/rman_$timst<

run{

allocate channel dev1 type disk ;

allocate channel dev2 type disk ;

backup incremental level 1 database format '/u01/backup/DEX/backups/$timst/bk_%t_%s' plus archivelog format'/u01/backup/DEX/backups/$timst/arc_%t_%s' linux iis7站长之家 all input ;

crosscheck backup ;

delete noprompt obsolete ;

delete noprompt expired backup;

}

EOF


不要忘记建立相应的目录


    
 
 
 
本站(WWW.)旨在分享和传播互联网科技相关的资讯和技术,将尽最大努力为读者提供更好的信息聚合和浏览方式。
本站(WWW.)站内文章除注明原创外,均为转载、整理或搜集自网络。欢迎任何形式的转载,转载请注明出处。












  • 相关文章推荐
  • rman配置及rman常用命令操作
  • Oracle相关:Rman Crosscheck删除失效归档
  • rman恢复方案和oracle异机恢复
  • Oracle RMAN快速入门指南


  • 站内导航:


    特别声明:169IT网站部分信息来自互联网,如果侵犯您的权利,请及时告知,本站将立即删除!

    ©2012-2021,