Linux环境下的一个rman备份的实例脚本(转载)
上一篇 / 下一篇 2008-01-22 16:32:14 / 个人分类:网文摘录
转载自:http://hi.baidu.com/odba/blog/item/105a4e06a852f37a03088178.html
背景:目标数据库192.168.1.172 Redhat Linux AS 3.0 Oracle 9.2.0.6ITPUB个人空间9QlyW]
恢复目录数据库 192.168.1.244 Windows2000 Oracle 9.2.0.1 rman/rman
1、配置catalog恢复目录
,C
E5o/]b0 create tablespace ts_rman datafile='d:oratestrman.dbf' size=100M;ITPUB个人空间S+JmHCX2k
create user rman identified by rman default tablespace ts_rman;
;nX e1L
c&NS?F0 grant connect ,resource , RECOVERY_CATALOG_OWNER to rman;
2uY3gx,H3n.f0
#MLhlG0 连接到目标数据库和CATALOG数据库
0a^WzM
W}1WR0 rman target / catalogrman/rman@244
`*Sc7nqtQ"m0
j'_U0f'xU0 创建CATALOG用户的表,登记目标数据库
*~ zt-WS#i0 rman> create catalogITPUB个人空间'^g Q!ji'kk]
rman> register databaseITPUB个人空间xi!A1v'q7F AC
ITPUB个人空间,WB1CD$NZ
y6y:^5F
配置参数
9v,G{+r,k0 rman> configure controlfile autobackup on;ITPUB个人空间8}+hB/Z_:q
rman> configure backup optimization on;
2、rman备份方案
l)\F(@0@K0 每周日晚做一次零级备份,周一到周六做一次一级备份
ED+l7J`'z9R0 ITPUB个人空间2~bhSNwI"e/p
************************************************************************ITPUB个人空间FG!`K;`G%U
Gf
*** rman_bk_L0.sh ***
0]rA6^p&X'QI0************************************************************************ITPUB个人空间&`,\|-N5y!k c O
#!/bin/sh
source /home/oracle/.bash_profile
cd $ORACLE_HOME/bin
./rman target / catalogrman/rman@244msglog=/home/oracle/work/log/rman_bk_L0_`date '+%Y%m%d%H%M%S'`.log <<EOF
run {ITPUB个人空间%J]!ti~/I;N
allocate channel c1 type disk;ITPUB个人空间A ]*QA#{2\$U
backup incremental level 0 filesperset 5 tag 'dbL0' format '/mnt/raid/rman_bk/ora_o_%d_%t%s%p%u' database skip readonly;
"C:r!M*W/wc@r8r4Z0sql 'alter system archive log current' ;ITPUB个人空间!r
AJ|;a
backup(archivelog all format '/mnt/raid/rman_bk/ora_a_%d_%t%s%p%u');
/h\gF@+F.n-ND ?d^0release channel c1;
,kU`,LV;Z%jHr-F*B0}
list backup;
pQd~d C,KN Nb[0exit;
EOF
ITPUB个人空间]`;p4Ld
************************************************************************
!f3Qe.R4J d0*** rman_bk_L1.sh ***
8rA:Z fxJ$zxE0************************************************************************ITPUB个人空间9T*h,gt,VZ{N5c
#!/bin/sh
source /home/oracle/.bash_profile
cd $ORACLE_HOME/bin
./rman target / catalogrman/rman@244msglog=/home/oracle/work/log/rman_bk_L1_`date '+%Y%m%d%H%M%S'`.log <<EOF
run {ITPUB个人空间aVK~1Em?fP
allocate channel c1 type disk;
j'm&xld*c&I8B0backup incremental level 1 filesperset 5 tag 'dbL1' format '/mnt/raid/rman_bk/ora_o_%d_%t%s%p%u' database skip readonly;
s3t[e+H0sql 'alter system archive log current' ;
3xPehr)gr1o0backup(archivelog all format '/mnt/raid/rman_bk/ora_a_%d_%t%s%p%u');ITPUB个人空间HPH(S6}
G
release channel c1;
9zm,X7l
w@ I0}
list backup;
5X:n3K5Z1R*r0exit;
EOF
然后使用crontab命令在linux上安排job如下:
00 02 * * 0 /home/oracle/work/bin/rman_bk_L0.shITPUB个人空间Z9N&Q7Y;Z9D!o0r
00 02 * * 1,2,3,4,5,6 /home/oracle/work/bin/rman_bk_L1.sh
注意:每周一要将冗余的备份手工清除掉
~?+{U3r[(df0rman> report obsolete;ITPUB个人空间:a-O o9_K
rman> delete obsolete;
导入论坛 引用链接 收藏 分享给好友 推荐到圈子 管理 举报
TAG: