簡單的使用rman備份oracle資料庫的做法

bomei發表於2007-07-17

#按照策略進行備份,這裡設定一個星期中的每一天的備份級別
#!/bin/bash
# rman.sh:
# This program is used to backup database ,carrying out backup's strategy.
#
# How to use this shell script
# cd /home/orapord/scripts/DB;sh rman.sh 2>/home/oraprod/output/rman_`date +%m%d%y`.error.log
#
#
# Authors:
#
# History:
#

. /u01/prod/oraprod/proddb/9.2.0/PROD_erp.env
PATH=$PATH:/home/oraprod/proddb/9.2.0/appsutil/scripts/PROD_erp
export PATH;
weekN=`date |awk '{print $1}'`
dateN=`date +\%m\%d\%y`
pathN=/home/oraprod
retain=/u02/retain
prodrman=/u02/prodrman
export weekN dateN pathN retain prodrman


cd $pathN/scripts/DB

case $weekN in

"Sun")
echo "Starting Incremental Level 0 Backup"
sh dbL0.sh 2>$pathN/output/dbL0_$dateN.error.log
sh movebackupset.sh
;;

"Mon")
echo "Starting Incremental Level 2 Backup"
sh dbL2.sh 2>$pathN/output/dbL2_$dateN.error.log
sh movebackupset.sh
;;

"Tue")
echo "Starting Incremental Level 2 Cumulative Backup"
sh dbL2C.sh 2>$pathN/output/dbL2C_$dateN.error.log
sh movebackupset.sh
;;

"Wed")
echo "Starting Incremental Level 1 Backup"
sh dbL1.sh 2>$pathN/output/dbL1_$dateN.error.log
sh movebackupset.sh
;;

"Thu")
echo "Starting Incremental Level 2 Backup"
sh dbL2.sh 2>$pathN/output/dbL2_$dateN.error.log
sh movebackupset.sh
;;

"Fri")
echo "Starting Incremental Level 2 Cumulative Backup"
sh dbL2C.sh 2>$pathN/output/dbL2C_$dateN.error.log
sh movebackupset.sh
;;

"Sat")
echo "Starting Incremental Level 2 Cumulative Backup"
sh dbL2C.sh 2>$pathN/output/dbL2C_$dateN.error.log
sh movebackupset.sh
;;

*)
echo "This script run failure"
;;

esac
exit 0

再寫幾個按照備份級別備份資料庫的簡單指令碼,例如:

# Database Incremental Level 0 Backup

rman target / log $pathN/output/dbL0_$dateN.log<run
{
backup incremental level 0 tag 'dbL0' database;
sql 'alter system archive log current';
backup archivelog all tag 'dblog' delete all input;
}
exit
EOF

再寫一個指令碼或者用備份軟體把備份集移動到你的儲存上就OK了!

這麼做確實簡單吧!呵呵,

不過很多公司還是使用專業的備份軟體來備份資料庫,我個人覺得這樣做對了解資料庫是有好處的。有機會用到的朋友可以效仿一下!

ice feng

2007-07-17 上午11時38分

[@more@]

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

相關文章