我在linux 中使用rman 備份指令碼

tieshuai發表於2008-07-18

1:

在/home/oracle (安裝帳號)中,修改 .bash_profile 檔案檢視環境變數

# User specific environment and startup programs

ORACLE_BASE=/usr/local/oracle
ORACLE_HOME=$ORACLE_BASE/product/10.2.0/db_1
ORACLE_SID=mrp
LC_CTYPE=en_US.UTF-8
LD_LIBRARY_PATH=$ORACLE_HOME/lib:/usr/lib
PATH=$PATH:$HOME/bin:$ORACLE_HOME/bin
22
[1]+  Stopped                 more .bash_profile
[oracle@cnsrv161 ~]$

2: 

呼叫0級備份指令碼:
[oracle@cnsrv161 ~]$ more backup_0_sun.sh
PATH=$PATH:$HOME/bin
ORACLE_BASE=/usr/local/oracle
ORACLE_SID=mrp
LD_LIBRARY_PATH=$ORACLE_HOME/lib
ORACLE_HOME=$ORACLE_BASE/product/10.2.0/db_1
export ORACLE_HOME
export ORACLE_BASE
export ORACLE_SID
export LD_LIBRARY_PATH
PATH=$PATH:$HOME/bin:$ORACLE_HOME/bin
export PATH
unset USERNAME
$ORACLE_HOME/bin/rman target / @/home/oracle/backup_0_sun.rms log=/home/oracle/`
date +%y-%m-%d`_full.log

3:

0 級備份指令碼:
[oracle@cnsrv161 ~]$ more backup_0_sun.rms
run{
allocate channel c1 type disk maxpiecesize=8G;
allocate channel c2 type disk maxpiecesize=8G;
allocate channel c3 type disk maxpiecesize=8G;
allocate channel c4 type disk maxpiecesize=8G;
BACKUP INCREMENTAL level 0 database filesperset=10;
BACKUP archivelog all delete all input;
delete obsolete;
}
[oracle@cnsrv161 ~]$

4:

linux 中配置任務,自動運新

[root@cnsrv161 etc]# more crontab
SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root
HOME=/

# run-parts
01 * * * * root nice -n 19 run-parts --report /etc/cron.hourly
02 1 * * * root nice -n 19 run-parts --report /etc/cron.daily
22 4 * * 0 root nice -n 19 run-parts --report /etc/cron.weekly
42 4 1 * * root nice -n 19 run-parts --report /etc/cron.monthly
01 00 * * 7 oracle . /home/oracle/backup_0_sun.sh
01 00 * * 1-6 oracle . /home/oracle/backup_1_sun.sh

[root@cnsrv161 etc]#


 

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

相關文章