每天系统自动执行RMAN备份后,为了便于管理,我以前都是在系统上手工创建一个目录RMAN`date +%Y%m%d`(如RMAN20061018),然后把当天备份的文件mv到RMAN`date +%Y%m%d`,由于磁盘空间有限,每次总要手工删除几天前的备份集,手工删除容易犯错误(目录名称差不多,RMAN20061016,RMAN20061017,RMAN20061018).
为此,我在系统上创建一个脚本backupsets.sh
-------------------------------------------------
#####BEGIN mv today backupdata
cd /dbback/databack;
mkdir RMAN`date +%Y%m%d`;
mv ar* full* RMAN`date +%Y%m%d`;
#####END mv today backupdata
######BEGIN copy a backup
cp -r RMAN`date +%Y%m%d` /ora/saebackup/databack/ &;
######END copy a backup
######BEGIN delete backupsets 3 days age
find /ora/saebackup/databack/ -mtime +3 -exec rm -r {} \;
######END delete backupsets 3 days age
######BEGIN delete backupsets 7 days age
find . -mtime +7 -exec rm -r {} \;
######END delete backupsets 7 days age
RMAN备份时使用的脚本
---------------------------------------------------
rman_backup_D.sh(crontab调用)
---------------------------------
###### RMAN BACKUP BEGIN ######
dt=`date +%Y%m%d`
rman catalog rman/rman target cmdfile /home/oracle/scripts/rman.sql log /home/oracle/log/rman_${dt}.log
###### RMAN BACKUP END #######
rman.sql
---------------------------------
run
{ allocate channel node1 type disk;
set limit channel node1 kbytes=2000000;
sql 'alter system archive log current';
backup format '/dbback/databack/full%n%s%p%t' ( database include current controlfile);
backup format '/dbback/databack/arch%n%s%p' (archivelog like '/dbback/log/arch%' delete input channel node1);
release channel node1;
}
阅读(2625) | 评论(0) | 转发(0) |