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