rman全库备份脚本

#!/bin/bash
#this is rman auto full backup script
#Copyright by 21og
#date 2012-03-21
export ORACLE_SID=orcl
export ORACLE_HOME=/opt/oracle/product/10.2/db_1
export ORACLE_BASE=/opt/oracle
export NLS_LANG="SIMPLIFIED CHINESE_CHINA.ZHS16GBK"
backtime=`date +"20%y%m%d%H%M%S"`
cd $ORACLE_HOME/bin
rman target / catalog rman/rman log=/opt/oracle/backup/log/backupall_$backtime.log <<EOF
run{
allocate channel c1 device type disk;
allocate channel c2 device type disk;
allocate channel c3 device type disk;
allocate channel c4 device type disk;
allocate channel c5 device type disk;
crosscheck backup;
sql 'alter system archive log current';
backup database format '/opt/oracle/backup/dbback/db_%d_%T_%U';
sql 'alter system archive log current';
backup archivelog all format '/opt/oracle/backup/logback/arc_%t_%s' delete all input;
backup current controlfile format '/opt/oracle/backup/controlfileback/cntrl_%s_%p_%s';
crosscheck archivelog all;
delete noprompt expired backup;
delete noprompt obsolete;
delete noprompt backup of database completed before 'sysdate - 30';
release channel c1;
release channel c2;
release channel c3;
release channel c4;
release channel c5;
}
EOF
echo "backup complete!"

 

---crontab自动执行

   1)以root身份编辑cron.allow文件,手动添加oracle用户允许使用cron服务。
  启动cron服务 /etc/init.d/cron start

   2)以oracle身份执行crontab -e

       0 0 * * 0 /opt/oracle/backup/script/dbback.sh 2>&1 >/dev/null

/*

delete expired删除的是那些本来RMAN以为存在但是实际上在磁盘或者磁带上已经被删除了的信息,删除的只是RMAN资料库中的记录;

delete obsolete则删除旧于备份保留策略定义的备份数据同时也更新RMAN资料库以及控制文件

*/

posted @ 2017-02-17 15:03  嘻哈怒叱  阅读(915)  评论(0编辑  收藏  举报