Chinaunix首页 | 论坛 | 博客
  • 博客访问: 103783
  • 博文数量: 18
  • 博客积分: 1483
  • 博客等级: 上尉
  • 技术积分: 217
  • 用 户 组: 普通用户
  • 注册时间: 2009-09-29 09:52
文章分类

全部博文(18)

文章存档

2011年(1)

2010年(17)

我的朋友

分类: Oracle

2010-08-29 20:11:25

共享出自己前段时间为客户写的一个数据库的备份脚本。

#!/bin/bash


#oracle env

export ORACLE_BASE=/opt/oracle
export ORACLE_HOME=/opt/oracle/product/10.2.0/db_1
export ORACLE_OWNER=oracle
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:$ORACLE_HOME/lib32:/lib:/usr/lib
export NLS_LANG=AMERICAN_AMERICA.AL32UTF8
export PATH=$PATH:$ORACLE_HOME/bin
export ORACLE_SID=yjsdb
export LANG=en_US
export CLASSPATH=$ORACLE_HOME/jre:$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib:$ORACLE_HOME/network/jlib

##backup

DATE=`date '+%Y-%m-%d-%H'`
cd /backup/yjsdb/
mkdir $DATE
cd $DATE
mkdir archivebackup

$ORACLE_HOME/bin/rman<<EOF
connect target

RUN {
crosscheck backup;
delete noprompt expired backup;
report obsolete;
delete noprompt obsolete;
allocate channel c1 device type disk;
allocate channel c2 device type disk;
allocate channel c3 device type disk;
allocate channel c4 device type disk;
backup full skip inaccessible tag yjsdb$DATE filesperset 5 format '/backup/yjsdb/$DATE/bak_%U_%s_%T.db' (database);
release channel c1;
release channel c2;
release channel c3;
release channel c4;
sql 'alter system archive log current';
allocate channel d1 type disk MAXPIECESIZE = 4G;
allocate channel c2 device type disk;
backup tag yjsdb_arc$DATE archivelog all format='/backup/yjsdb/$DATE/archivebackup/arc_%d_%s_%p.bak' delete all input;
backup spfile format '/backup/yjsdb/$DATE/spfileYJSDB_%s_%t';
release channel d1;
release channel d2;
allocate channel d3 device type disk;
backup tag yjsdb_ctl$DATE format '/backup/yjsdb/$DATE/contrl_%s_%p_%t' current controlfile;
release channel d31;
}
exit;

EOF


阅读(6206) | 评论(0) | 转发(1) |
给主人留下些什么吧!~~