Linux環境下的一個rman備份的例項指令碼(轉載)

浪漫雙魚發表於2008-01-22

轉載自:http://hi.baidu.com/odba/blog/item/105a4e06a852f37a03088178.html

背景:目標資料庫192.168.1.172   Redhat Linux AS 3.0   Oracle 9.2.0.6
          恢復目錄資料庫 192.168.1.244   Windows2000   Oracle 9.2.0.1 rman/rman

1、配置catalog恢復目錄
    create tablespace ts_rman datafile='d:oratestrman.dbf' size=100M;
    create user rman identified by rman default tablespace ts_rman;
    grant connect ,resource , RECOVERY_CATALOG_OWNER to rman;
   
    連線到目標資料庫和CATALOG資料庫
    rman target / catalog rman/rman@244
   
    建立CATALOG使用者的表,登記目標資料庫
    rman> create catalog
    rman> register database
   
    配置引數
    rman> configure controlfile autobackup on;
    rman> configure backup optimization on;

2、rman備份方案
    每週日晚做一次零級備份,週一到週六做一次一級備份
   
************************************************************************
***                           rman_bk_L0.sh                            ***
************************************************************************
#!/bin/sh

source /home/oracle/.bash_profile

cd $ORACLE_HOME/bin

./rman target / catalog rman/rman@244 msglog=/home/oracle/work/log/rman_bk_L0_`date '+%Y%m%d%H%M%S'`.log <

run {
allocate channel c1 type disk;
backup incremental level 0 filesperset 5 tag 'dbL0' format '/mnt/raid/rman_bk/ora_o_%d_%t%s%p%u' database skip readonly;
sql 'alter system archive log current' ;
backup(archivelog all format '/mnt/raid/rman_bk/ora_a_%d_%t%s%p%u');
release channel c1;
}

list backup;
exit;

EOF


************************************************************************
***                           rman_bk_L1.sh                            ***
************************************************************************
#!/bin/sh

source /home/oracle/.bash_profile

cd $ORACLE_HOME/bin

./rman target / catalog rman/rman@244 msglog=/home/oracle/work/log/rman_bk_L1_`date '+%Y%m%d%H%M%S'`.log <

run {
allocate channel c1 type disk;
backup incremental level 1 filesperset 5 tag 'dbL1' format '/mnt/raid/rman_bk/ora_o_%d_%t%s%p%u' database skip readonly;
sql 'alter system archive log current' ;
backup(archivelog all format '/mnt/raid/rman_bk/ora_a_%d_%t%s%p%u');
release channel c1;
}

list backup;
exit;

EOF

然後使用crontab命令在linux上安排job如下:

00 02 * * 0 /home/oracle/work/bin/rman_bk_L0.sh
00 02 * * 1,2,3,4,5,6 /home/oracle/work/bin/rman_bk_L1.sh

注意:每週一要將冗餘的備份手工清除掉
rman> report obsolete;
rman> delete obsolete;

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/11088128/viewspace-157067/,如需轉載,請註明出處,否則將追究法律責任。

相關文章