自己写的RMAN备份脚本

一套自己写的rman备份脚本,包含全量、增量和归档日志备份,备份策略为每7天一个全备份,2天一个增量备份和每8小时一次归档备份,并删除一个月前的备份和归档。

 

 



crontab 



0 0,8,16 * * * sh /home/oracle/backup_script/backup-archive.sh >> /home/oracle/backup_script/backup-archive.log
0 0 7,14,21,28 * * sh /home/oracle/backup_script/backup-full.sh >> /home/oracle/backup_script/backup-full.log
0 0 2,4,6,8,10,12,16,18,20,22,24,26 * * sh /home/oracle/backup_script/backup-inc.sh >> /home/oracle/backup_script/backup-inc.log




FULL 

sql 'alter system archive log current';
sql "alter session set nls_date_format=''dd.mm.yyyy hh24:mi:ss''";
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;
backup AS COMPRESSED BACKUPSET incremental level 0  database tag ORCL_FULL format '/oracle_bak/oradir/%d_%T_%s_%p_FULL' ;
sql 'alter system archive log current';
backup as compressed backupset tag ORCL_ARCHIVE format '/oracle_bak/oradir/%d_%T_%s_%p_ARCHIVE' archivelog all not backed up delete all input ;
delete backup of archivelog until time='sysdate-30';
backup tag ORCL_CONTROL current controlfile format '/oracle_bak/oradir/%d_%T_%s_%p_CONTROL';
release channel c1;
release channel c2;
release channel c3;
release channel c4;
}




INC


sql 'alter system archive log current';
sql "alter session set nls_date_format=''dd.mm.yyyy hh24:mi:ss''";
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;
backup AS COMPRESSED BACKUPSET incremental level 1  database tag ORCL_INC1 format '/oracle_bak/oradir/%d_%T_%s_%p_INC1' ;
sql 'alter system archive log current';
backup tag ORCL_CONTROL current controlfile format '/oracle_bak/oradir/%d_%T_%s_%p_CONTROL';
release channel c1;
release channel c2;
release channel c3;
release channel c4;
}



ARCHIVE 

sql "alter session set nls_date_format=''dd.mm.yyyy hh24:mi:ss''";
RUN
{
allocate channel c1 type disk MAXOPENFILES=1 parms ' BLKSIZE=1048576 ';
allocate channel c2 type disk MAXOPENFILES=1 parms ' BLKSIZE=1048576 ';
allocate channel c3 type disk MAXOPENFILES=1 parms ' BLKSIZE=1048576 ';
allocate channel c4 type disk MAXOPENFILES=1 parms ' BLKSIZE=1048576 ';
sql 'alter system archive log current';
backup as compressed backupset tag ORCL_ARCHIVE format '/oracle_bak/oradir/%d_%T_%s_%p_ARCHIVE' archivelog all not backed up delete all input ;
delete backup of archivelog until time='sysdate-30';
backup tag ORCL_CONTROL current controlfile format '/oracle_bak/oradir/%d_%T_%s_%p_CONTROL';
release channel c1;
release channel c2;
release channel c3;
release channel c4;
}

Comment

*

沪ICP备14014813号-2

沪公网安备 31010802001379号