linux下rman增量備份指令碼以及指令碼自動執行

773281375發表於2014-03-08
一、增量備份指令碼
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執行增量備份



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

相關文章