Chinaunix首页 | 论坛 | 博客
  • 博客访问: 284770
  • 博文数量: 48
  • 博客积分: 1255
  • 博客等级: 中尉
  • 技术积分: 486
  • 用 户 组: 普通用户
  • 注册时间: 2009-09-01 18:28
文章分类

全部博文(48)

文章存档

2014年(10)

2012年(9)

2011年(17)

2010年(9)

2009年(3)

我的朋友

分类: LINUX

2010-12-08 22:27:48

-bash-3.00#cat rman_db_level0.sh
#!/bin/sh
ORACLE_BASE=/oracle/app/oracle
ORACLE_HOME=$ORACLE_BASE/product/8.1.6
DB_SID=aflc
ORA_NLS33=$ORACLE_HOME/ocommon/nls/admin/data
NLS_LANG=AMERICAN_TAIWAN.ZHT16BIG5
export ORACLE_BASE ORACLE_HOME ORA_NLS33 NLS_LANG
unset LANG


#User and Password for rcat catalog owner
USER=rman
PASS=rman
RMAN_SID=rcat

BACKDIR=/aflcdash/orabup
ps -ef | grep $DB_SID | grep ora_ > /dev/null
if [ $? != 0 ]
then
$ORACLE_HOME/bin/svrmgrl << EOF
connect internal
startup
exit
EOF
fi

echo "*****Startup Recovery Catalog Database*****"
ps -ef | grep $RMAN_SID | grep ora_ > /dev/null
if [ $? != 0 ]
then
ORACLE_SID=$RMAN_SID
export ORACLE_SID
$ORACLE_HOME/bin/svrmgrl << EOF
connect internal
startup
exit
EOF
fi

ORACLE_SID=$DB_SID
export ORACLE_SID
DATE=`date "+%Y%m%d%H%M"`

echo "-----Begin Level0 Database Backup-----"
date

cp $ORACLE_BASE/admin/${ORACLE_SID}/pfile/init${ORACLE_SID}.ora $BACKDIR/init${ORACLE_SID}.$DATE
cp $ORACLE_BASE/admin/${ORACLE_SID}/pfile/config${ORACLE_SID}.ora $BACKDIR/config${ORACLE_SID}.$DATE

$ORACLE_HOME/bin/rman catalog $USER/$PASS@rcat << EOF
connect target
run {
set command id to 'rman_level0';
allocate channel d1 type disk;
allocate channel d2 type disk;
setlimit channel d1 kbytes 2097000 maxopenfiles 32 readrate 200;
setlimit channel d2 kbytes 2097000 maxopenfiles 32 readrate 200;
sql 'alter database backup controlfile to trace';
copy
current controlfile to '$BACKDIR/${ORACLE_SID}_control.$DATE';

sql 'alter system archive log current';

backup
filesperset 50
format '$BACKDIR/${ORACLE_SID}_log_%U.$DATE'
(archivelog all
delete input);

backup
incremental level 0
tag db_level0
filesperset 10
format '$BACKDIR/${ORACLE_SID}_level0_data_%U.$DATE'
(database);

release channel d1;
release channel d2;
}
exit
EOF
date
echo "-----End Level0 Database Backup-----"

echo "*****Shutdown Recovery Catalog Database*****"
ORACLE_SID=$RMAN_SID
export ORACLE_SID
$ORACLE_HOME/bin/svrmgrl << EOF
connect internal
shutdown
exit
EOF
echo " "
echo " "
阅读(1018) | 评论(1) | 转发(0) |
给主人留下些什么吧!~~

chinaunix网友2010-12-09 15:20:47

很好的, 收藏了 推荐一个博客,提供很多免费软件编程电子书下载: http://free-ebooks.appspot.com