###################### START ########################
#!/bin/bash
drhost=`GFCDROBIEEDB1`
tstamp=`date +"%c"`
email="ravi@ecsme.ae"
myLog="/home/oracle/rmanDelStandbyArclogs.log"
if [ "$1" == "" ]; then
echo "Error: Improper arguments"
echo ""
echo "Correct format"
echo "$0 ORACLE_SID"
exit -1
fi
export ORACLE_SID="$1"
export ORACLE_HOME="/swapphome/oracle/app/product/11.2.0/db_2"
export PATH="$ORACLE_HOME/bin:$PATH"
sequence=`sqlplus -s '/as sysdba' << EOF
set head off
set feed off
set echo off
select max(sequence#) from v\\\$archived_log where applied='YES' group by applied;
exit;
EOF`
if [ `echo $sequence | grep ORA- | wc -l` -ge "1" ]; then
echo "Error: [$sequence]"
echo $sequence | mailx -s "[$tstamp] Error: Removing applied standby archived logs from standby database [$1] on host [$drhost]" $email
exit -1
fi
sequence=`echo "$sequence" | tr -dc '[:alnum:]'`
rmanCmd="delete noprompt archivelog until sequence $sequence"
rmanDel=$(rman target / append log ${myLog} 2>&1 << END_OF_RMAN
$rmanCmd;
exit;
END_OF_RMAN
)
if [ `echo $rmanDel | grep RMAN- | wc -l` -ge "1" ]; then
echo "Error: [$rmanDel]"
echo $rmanDel | mailx -s "[$tstamp] Error: RMAN error while deleting applied archive logs from standby database [$1] on host [$drhost]" $email
exit -1
fi
exit 0
############################### END #############################
#!/bin/bash
drhost=`GFCDROBIEEDB1`
tstamp=`date +"%c"`
email="ravi@ecsme.ae"
myLog="/home/oracle/rmanDelStandbyArclogs.log"
if [ "$1" == "" ]; then
echo "Error: Improper arguments"
echo ""
echo "Correct format"
echo "$0 ORACLE_SID"
exit -1
fi
export ORACLE_SID="$1"
export ORACLE_HOME="/swapphome/oracle/app/product/11.2.0/db_2"
export PATH="$ORACLE_HOME/bin:$PATH"
sequence=`sqlplus -s '/as sysdba' << EOF
set head off
set feed off
set echo off
select max(sequence#) from v\\\$archived_log where applied='YES' group by applied;
exit;
EOF`
if [ `echo $sequence | grep ORA- | wc -l` -ge "1" ]; then
echo "Error: [$sequence]"
echo $sequence | mailx -s "[$tstamp] Error: Removing applied standby archived logs from standby database [$1] on host [$drhost]" $email
exit -1
fi
sequence=`echo "$sequence" | tr -dc '[:alnum:]'`
rmanCmd="delete noprompt archivelog until sequence $sequence"
rmanDel=$(rman target / append log ${myLog} 2>&1 << END_OF_RMAN
$rmanCmd;
exit;
END_OF_RMAN
)
if [ `echo $rmanDel | grep RMAN- | wc -l` -ge "1" ]; then
echo "Error: [$rmanDel]"
echo $rmanDel | mailx -s "[$tstamp] Error: RMAN error while deleting applied archive logs from standby database [$1] on host [$drhost]" $email
exit -1
fi
exit 0
############################### END #############################
No comments:
Post a Comment