linux自动运行rman增量备份脚本

一、增量备份脚本
0级备份脚本:红色部分为自定义的备份文件放置的目录

复制代码 代码如下:

#script.:backupfull.sh

#creater:xyh

#date:2014-03-08

#desc:backup full database datafile in archive with rman

#connect database

export oracle_base=/u01/app/oracle

export oracle_sid=orcl

export oracle_home=/u01/app/oracle/product/10.2.0/db_1

export path=$oracle_home/bin:$path

rman target/ << eof_rman

run{

allocate channel c1 type disk;

backup incremental level 0 tag ‘db0’ format

‘/home/oracle/rmanbackup/db0_%d_%t_%s’ database include current controlfile;

sql ‘alter system archive log current’;

backup filesperset 5 format ‘/home/oracle/rmanbackup/cf0_%d_%t_%s’ archivelog all delete input;

#filesperset 5表示备份集里面最多包含5个文件 

delete noprompt obsolete;

release channel c1;

}

# end

1级备份脚本

复制代码 代码如下:

#script.:incrl.sh

#creater:xyh

#date:2014-03-08

#desc:backup full database datafile in archive with rman

#connect database

export oracle_base=/u01/app/oracle

export oracle_sid=orcl

export oracle_home=/u01/app/oracle/product/10.2.0/db_1

export path=$oracle_home/bin:$path

rman target/ << eof_rman

run{

allocate channel c1 type disk;

backup incremental level 1 tag ‘db1’ format

‘/home/oracle/rmanbackup/db1_%d_%t_%s’ database include current controlfile;

sql ‘alter system archive log current’;

backup filesperset 5 format ‘/home/oracle/rmanbackup/cf1_%d_%t_%s’ archivelog all delete input;

#filesperset 5表示备份集里面最多包含5个文件 

delete noprompt obsolete;

release channel c1;

}

#end

二、使用linux的crontab设置自动执行备份


复制代码 代码如下:

crontab -e

按enter后,可以像vi编辑器一样输入下面内容


复制代码 代码如下:

0 1 * * 0 /home/oracle/backupfull.sh >>/home/oracle/backupfull.log

0 1 * * 3 /home/oracle/backupfull.sh >>/home/oracle/backupfull.log

30 1 * * 1-2 /home/oracle/incrl.sh >>/home/oracle/incr.log

30 1 * * 4-6 /home/oracle/incrl.sh >>/home/oracle/incr.log

查看crontab内容:crontab -l

注:上面意思是把全库备份日志写到/home/oracle/backupfull.log文件中,而增量备份日志写到/home/oracle/incr.log中

周日和周三凌晨1:00执行0级全库备份,周一、二、四、五、六凌晨1:30执行增量备份

(0)
上一篇 2022年3月22日
下一篇 2022年3月22日

相关推荐