您的位置:首页 > 其它

RMAN配置自动增量备份

2013-05-29 16:47 507 查看
#!/bin/bash

set -e

#############################################################
# sunday incremental level 0
# other day incremental level 1
#

#############################################################

export ORACLE_HOME=/home/oracle/app/oracle/product/11.2.0/dbhome_2
rman_bin=$ORACLE_HOME/bin/rman

weekday=`date +%a`
case "${weekday}" in

"Sun")
inc_level=0
;;

"Wed")
inc_level=1
;;

*)
inc_level=1
;;
esac

rman_user=sys
rman_passwd=oracle
catalog_inst_name=orcl

target_sys_passwd=oracle
target_inst_name=orcl

log_file=/home/oracle/tmp/backup/log/`date +%F`_${inc_level}.log
bak_file=/home/oracle/tmp/backup/bkfile/'bak_%T_%U'
arc_file=/home/oracle/tmp/backup/bkfile/'arc_%T_%U'
ctl_file=/home/oracle/tmp/backup/bkfile/'ctl_%F'

$rman_bin log ${log_file} >> /dev/null 2>&1 <<EOF

connect catalog ${rman_user}/${rman_passwd}@${catalog_inst_name};
connect target sys/${target_sys_passwd}@${target_inst_name};

run {
configure backup optimization on;
configure archivelog deletion policy to applied on standby;
configure retention policy to redundancy 3;
configure controlfile autobackup on;
configure controlfile autobackup format for device type disk to '${ctl_file}';

allocate channel ch1 device type disk;
backup incremental level ${inc_level} cumulative database format '${bak_file}' skip readonly plus archivelog format '${arc_file}';

release channel ch1;
}

crosscheck backup;
delete noprompt obsolete;

delete noprompt archivelog all completed before 'sysdate - 14';

exit;
EOF

exit 0

******

用cron创建定时执行任务,默认情况下,cron为开机自动启动的
执行 crontab –e 添加以下语句:
00 01 * * * sh /u01/backup/backup.sh
保存退出
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: