1个RMAN的shell脚本

[| 不指定 2007/07/11 16:58]
| |

-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 " "


本文链接:http://www.52zhe.cn/read.php/58.htm
本文作者:kook(若就博客内所涉及的技术问题交流,请用下面的MSN或Gmail联系我)
联系方式:(MSN:kook#live.com) (Google talk:kookliu)
没有版权:GNU,转载时请注明“转载人”欠本人一顿饭,来日见面之时兑现!谢谢合作!
by kook | 分类: Oracle | 评论(0) | 引用(0) | 阅读(1390)
发表评论
表情
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
打开HTML
打开UBB
打开表情
隐藏
记住我
昵称   密码   游客无需密码
网址   电邮   [注册]