Oracle 10G 归档模式下备份脚本

        这是一个生产库的rman备份shell脚本,分为 0级备份 与1级差异累积备份,每周一次0级别备份,其他1级差异累积备份。(尊重原创,转载请标明出处http://blog.csdn.net/zonelan)

1、0级别备份shell 脚本:

#!/bin/sh
#### 2011.6.27 ####
#level=0#
export TMP=/tmp
export TMPDIR=/tmp
export ORACLE_BASE=/opt/oracleonder
export ORACLE_HOME=$ORACLE_BASE/product/10.2.0/db_1
export ORACLE_SID=onder
export PATH=$PATH:$ORACLE_HOME/bin:
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib
export BAKFILE=/opt/bak/bak0.log
find /opt/bak/archbak -mtime +365 -name "arch*.tar.bz2" -exec rm -rf {} \;  ###因为每周只执行0级备份,归档日志不能自动删除(只有执行##全备,归档备份才会被设置为无效),所以这里写了一条命令来删除保存策略外的归档日志备份。
rman nocatalog target / msglog $BAKFILE << EOF
run{
CONFIGURE CONTROLFILE AUTOBACKUP ON;
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '/opt/bak/conf_%F_%T.tar.bz2';
CONFIGURE RETENTION POLICY TO REDUNDANCY 20;
configure device type disk parallelism 1 backup type to compressed backupset;
report obsolete;
delete noprompt obsolete;
crosscheck backup;
delete noprompt expired backup;
backup incremental level=0 database format '/opt/bak/bak_%T_%U_%t_%d.tar.bz2' plus archivelog format '/opt/bak/archbak/arch_%U_%s.tar.bz2';
DELETE noprompt ARCHIVELOG ALL COMPLETED BEFORE 'SYSDATE-30';
crosscheck archivelog all;  ##检查出系统中不存在的归档日志记录,虽然上边的命令是删除超过30天的归档日志,但是相关记录记#录依然存在。
delete noprompt expired archivelog all;  ###noprompt 参数是不需要确认直接删除,用脚本必备。
}
EOF

2、1级差异累积备份,差异累积备份的好处就是,故障恢复时只需要0级别+1级别 就可以了,不用像差异增量那样逐个叠加,方便恢复。
#!/bin/sh
#### 2011.6.27 ####
#level=1#
export TMP=/tmp
export TMPDIR=/tmp
export ORACLE_BASE=/opt/oracleonder
export ORACLE_HOME=$ORACLE_BASE/product/10.2.0/db_1
export ORACLE_SID=onder
export PATH=$PATH:$ORACLE_HOME/bin:
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib
export BAKFILE=/opt/bak/bak1.log
rman nocatalog target / msglog $BAKFILE << EOF
run{
CONFIGURE CONTROLFILE AUTOBACKUP ON;
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '/opt/bak/conf_%F_%T.tar.bz2';
CONFIGURE RETENTION POLICY TO REDUNDANCY 20;
configure device type disk parallelism 1 backup type to compressed backupset;
report obsolete;
delete noprompt obsolete;
crosscheck backup;
delete noprompt expired backup;
backup incremental level=1 cumulative database format '/opt/bak/bak1_%T_%U_%t_%d.tar.bz2';
DELETE noprompt ARCHIVELOG ALL COMPLETED BEFORE 'SYSDATE-30';
crosscheck archivelog all;  
delete noprompt expired archivelog all;  
}
EOF

加入到crontab中即可

# m h  dom mon dow   command

30 00 * * 2 /root/rmana/ssh0.sh

30 00 * * 0,1,3,4,5,6 /root/rmana/ssh1.sh

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值