RMAN - 常用的备份脚本 之三

0级全库备份脚本

$ vi BackupFull.sh

BackupFull.sh文件的内容为:

复制代码
# script .:BackupFull.sh

# creater:leon_lan

# date:2012/7/22

# desc: backup full database datafile in archive with rman

# connect database

Export ORACLE_BASE=/u01/app/oracle

Export ORACLE_HOME=/u01/app/oracle/product/10.2.0/db_1

Export ORACLE_SID=oms

Export PATH=$ORACLE_HOME/bin:$PATH

Rman target/ << EOF_RMAN

Run{

       Allocate channel c1 type disk;

       Backup incremental level 0 tag ‘db0’ format

       ‘/u01/app/oracle/RmanBackup/db0_%d_%T_%s’ database include current controlfile;

       Delete noprompt obsolete;

       Release channel c1;

}

#end
复制代码

1级增量备份脚本

$ vi Incr1.sh

Incr1.sh文件的内容为:

复制代码
# script .:BackupFull.sh

# creater:leon_lan

# date:2012/7/22

# desc: backup full database datafile in archive with rman

# connect database

Export ORACLE_BASE=/u01/app/oracle

Export ORACLE_HOME=/u01/app/oracle/product/10.2.0/db_1

Export ORACLE_SID=oms

Export PATH=$ORACLE_HOME/bin:$PATH

Rman target/ << EOF_RMAN

Run{

       Allocate channel c1 type disk;

       Backup incremental level 1 tag ‘db1’ format

       ‘/u01/app/oracle/RmanBackup/db1_%d_%T_%s’ database include current controlfile;

       Delete noprompt obsolete;

       Release channel c1;

}

#end
复制代码

设置自动化执行备份脚本

复制代码
$ crontab –e

0 1 * * 0 /u01/app/oracle/RmanBackup/BackupFull.sh

>>/u01/app/oracle/RmanBackup/BackupFull.log

0 1 * * 3 /u01/app/oracle/RmanBackup/BackupFull.sh

>>/u01/app/oracle/RmanBackup/BackupFull.log

30 1 * * 1-2 /u01/app/oracle/RmanBackup/Incr1.sh

>>/u01/app/oracle/RmanBackup/Incr.log

30 1 * * 4-6 /u01/app/oracle/RmanBackup/Incr1.sh

>>/u01/app/oracle/RmanBackup/Incr.log
复制代码

上面的内容的意思是周日和周三凌晨1:00执行0级全库备份,周一、二、四、五六凌晨1:30执行1级增量备份。

你可能感兴趣的:(RMAN - 常用的备份脚本 之三)