ITPub博客

首页 > Linux操作系统 > Linux操作系统 > 全备脚本

全备脚本

原创 Linux操作系统 作者:oralau 时间:2009-04-27 00:17:14 0 删除 编辑

创建备份目录

mkdir    -p   /mnt/oradata/ordrbak
chown  -R   oracle:dba  /mnt/oradata/ordrbak
chmod  -R   /mnt/oradata/ordrbak

设定控制文件自动备份
configure controlfile autobackup on;
配置备份策略
要求
星期日,三做全备
星期一,二,四,五,六备份归档日志
必须有两个可用备份;能够恢复到7天以内的任何时刻

configure retention policy to redundancy 2;
configure retention policy to recovery window of 7 days;

设定定时运行任务crontab  -e编辑

30 3 * * 0-6 /opt/oracle/dbmon/rmanbak/startrman.sh

编辑选择备份类型脚本startrman.sh

. /home/oracle/.bash_profile
SH_HOME=/home/oracle/.bash_profile
export SH_HOME
DATE=`date +"%Y%m%d"`
week=`date +"%w"`

#-----------------------------------------------------------------------
#Confirm whether the oracle is runing
#-----------------------------------------------------------------------
ps -ef|grep dbw0_$ORACLE_SID |grep -v grep >>/dev/null

#-----------------------------------------------------------------------
#Begin to backup
#-----------------------------------------------------------------------
if [ $? -eq 0 ]; then
   if [ $week = "0" ] || [ $week = "3" ] ; then
      rman target / @$SH_HOME/fullback.sql log=$SH_HOME/logs/rmanfullback`date +"%Y%m%d"`.log
   else
      rman target / @$SH_HOME/archback.sql log=$SH_HOME/logs/rmanarchback`date +"%Y%m%d"`.log
   fi
fi

编辑备数据文件脚本fullback.sql

run{                                                                                                              
allocate channel ch00 type  disk   maxpiecesize=1000m;                                                                            
allocate channel ch01 type  disk   maxpiecesize=1000m;                                                                            
allocate channel ch02 type  disk   maxpiecesize=1000m;                                                                            
backup  database include current controlfile format '/mnt/oradata/ordrbak/orderfullback_%d_%T_%s_%p' filesperset  3  plus
archivelog format '/mnt/oradata/ordrbak/orderarch_%d_%T_%s_%p' delete all input;                                           
release channel ch00;                                                                                               
release channel ch01;                                                                                                               
release channel ch02;
delete  noprompt  obsolete; 
}


编辑备份归档文件脚本archback.sql

run{     
allocate channel ch00 type  disk  maxpiecesize=1000m;  
allocate channel ch01 type  disk  maxpiecesize=1000m;  
allocate channel ch02 type  disk  maxpiecesize=1000m;                                                                             
backup archivelog all format '/mnt/oradata/ordrbak/orderarch_%d_%T_%s_%p' filesperset  3 delete all input;
release channel ch00;                                                                                               
release channel ch01;                                                                                                               
release channel ch02;
delete  noprompt  obsolete; 

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

下一篇: 增备脚本
请登录后发表评论 登录
全部评论

注册时间:2009-02-17

  • 博文量
    38
  • 访问量
    36770