ITPub博客

首页 > Linux操作系统 > Linux操作系统 > 转贴:RMAN备份脚本(Unix)

转贴:RMAN备份脚本(Unix)

原创 Linux操作系统 作者:tolywang 时间:2009-02-13 16:48:36 0 删除 编辑

注意:此文档是本人由网络资料整理而成

备份策略:

星期天 0 级

星期一,二,四,五六 2 级

星期三 1 级


--本地


mkdir /home/oracle/backup
mkdir /home/oracle/backup/script
mkdir /home/oracle/backup/log
mkdir /home/oracle/backup/export


--备份目的地
mkdir /home/oracle/rman_backup


create tablespace rman_tbs datafile '/oradata/luke/rman_tbs01.dbf' size 1024M;


create user rman identified by rman default tablespace rman_tbs temporary tablespace temp;


grant connect,resource ,recovery_catalog_owner to rman;


rman catalog rman/rman
create catalog tablespace rman_tbs;
connect target sys/lukewhx@luke
register database;
report schema;


configure retention policy to redundancy 2;
configure retention policy to recovery window of 7 days;


--倒出RMAN用户数据脚本exp_rman.par


userid=rman/rman
file=/home/oracle/backup/export/rman.dmp
log=/home/oracle/backup/log/rman.log


--倒出RMAN数据SHELL脚本exp_rman.sh
#!/bin/bash
cd $HOME
. .bash_profile
cd $HOME/backup/script
exp parfile=exp_rman.par

--零级备份RMAN脚本level0_backup.rcv
connect catalog rman/rman
connect target sys/unumall@unu2
run {
allocate channel d1 type disk;
allocate channel d2 type disk;
backup incremental level 0 database format '/home/oracle/rman_backup/level0_%d_%s_%p_%u.bak'
tag='level 0' include current controlfile;
sql 'alter system archive log current';
backup archivelog all format '/home/oracle/rman_backup/log_%d_%s_%p_%u.bak' delete all input;
release channel d2;
release channel d1;
}
crosscheck backup;
delete noprompt expired backup;
delete noprompt obsolete;
resync catalog;

--零级备份SHELL脚本的level0_backup.sh
#!/bin/bash
cd $HOME
. .bash_profile
cd $HOME/backup/script
rman cmdfile=level0_backup.rcv msglog=$HOME/backup/log/level0_backup.log
. /home/oracle/backup/script/exp_rman.sh

--一级差异增量备份RMAN脚本level1_backup.rcv
connect catalog rman/rman
connect target sys/luke@luke
run {
allocate channel d1 type disk;
backup incremental level 1 format '/home/oracle/rman_backup/level1_%d_%s_%p_%u.bak' tag = 'level 1' database;
sql 'alter system archive log current';
backup archivelog all format '/home/oracle/rman_backup/log_%d_%s_%p_%u.bak' delete all input;
release channel d1;
}
crosscheck backup;
delete noprompt expired backup;
delete noprompt obsolete;
resync catalog;

--一级差异增量备份SHELL脚本level1_backup.sh#!/bin/bash
cd $HOME
. .bash_profile
cd /home/oracle/backup/script
rman cmdfile=level1_backup.rcv msglog=$HOME/backup/log/level1.log
. /home/oracle/backup/script/exp_rman.sh

--二级差异增量备份RMAN脚本level2_backup.rcv
connect catalog rman/rman
connect target sys/luke@luke
run {
allocate channel d1 type disk;
backup incremental level 2 format '/home/oracle/rman_backup/level2_%d_%s_%p_%u.bak' tag = 'level 2' database;
sql 'alter system archive log current';
backup archivelog all format '/home/oracle/rman_backup/log_%d_%s_%p_%u.bak' delete all input;
release channel d1;
}
crosscheck backup;
delete noprompt expired backup;
delete noprompt obsolete;
resync catalog;

--二级差异增量备份SHELL脚本level2_backup.sh
#!/bin/bash
cd $HOME
. .bash_profile
cd /home/oracle/backup/script
rman cmdfile=level2_backup.rcv msglog=$HOME/backup/log/level2.log
. /home/oracle/backup/script/exp_rman.sh

提高RMAN增量备份性能

alter database enable block change tracking using file
'/u01/app/oracle/admin/devdb/bdump/luke.log';

desc v$block_change_tracking;

 

http://happyhou.blog.sohu.com/73368307.html 

 

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/35489/viewspace-551853/,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论
Oracle , MySQL, SAP IQ, SAP HANA, PostgreSQL, Tableau 技术讨论,希望在这里一起分享知识,讨论技术,畅谈人生 。

注册时间:2007-12-10

  • 博文量
    5595
  • 访问量
    13268732