Enviado em 21/01/2021 - 11:22h
Bom dia Galera,"#!/bin/bash
#####################################
source "/home/oracle/.bash_profile"
#####################################
export CLIENTE='besouro'
export PROPOSTA=''
export CWRK='/home/oracle/.scripts'
export NLS_DATE_FORMAT='DD-MON-YY HH24:MI:SS'
export DOW=$(date +%u)
export DIA_SEMANA='FER-FERIADO'
##
clear screen
export DIAHORA=$(date +%Y%m%d-%H%M%S)
export DOYB=$(date +%j)
export WORACLE_SID=BESOURO
export WRKDIR="/u01/backup_oracle"
case $DOW in
0) DIA_SEMANA='DOMINGO-FULL'
;;
7) DIA_SEMANA='DOMINGO-FULL'
;;
1) DIA_SEMANA='SEGUNDA'
;;
2) DIA_SEMANA='TERCA'
;;
3) DIA_SEMANA='QUARTA'
;;
4) DIA_SEMANA='QUINTA'
;;
5) DIA_SEMANA='SEXTA'
;;
6) DIA_SEMANA='SABADO'
;;
*) DIA_SEMANA='XXX-UNKNOWN'
;;
esac
clear
##
while [ -f "/tmp/backup_full.log" ] ;
do
echo "Rotina de backup executando, aguardando terminar."
cat /tmp/backup_full.log
exit 1
done
while [ -f "/tmp/backup_dpmp.log" ] ;
do
echo "Rotina de backup executando, aguardando terminar."
cat /tmp/backup_dpmp.log
exit 2
done
while [ -f "/tmp/backup_redo.log" ] ;
do
echo "Rotina de backup executando, aguardando terminar."
cat /tmp/backup_redo.log
exit 3
done
echo "Realizando Backup : $ORACLE_SID" > /tmp/backup_dpmp.log
## exclui backup antigo, caso exista
find "$WRKDIR/" -name "$WORACLE_SID.$DOYB.*" -type f -print -exec rm {} \;
find "$WRKDIR/" -name "$WORACLE_SID.*" -type f -ctime +5 -print -exec rm {} \;
find "$WRKDIR/" -name "*.log" -type f -ctime +5 -print -exec rm {} \;
find "$WRKDIR/" -name "*.dmp" -type f -ctime +5 -print -exec rm {} \;
##
for oUSER in RHMETA LINX
do
export DMPFILE=$WORACLE_SID.$DOYB.$oUSER.$DIAHORA.$DIA_SEMANA.tar.gz
echo "" > /tmp/$ORACLE_SID.par
if [ $DOW = 0 -o $DOW = 7 ];
then
echo "FULL=Y" >> /tmp/$ORACLE_SID.par
if [ $oUSER = 'RHMETA' ];
then
echo "EXCLUDE=SCHEMA:\"IN ( 'LINX', 'TREINO' )\"" >> /tmp/$ORACLE_SID.par
fi
if [ $oUSER = 'LINX' ];
then
echo "EXCLUDE=SCHEMA:\"IN ( 'RHMETA', 'TREINO' )\"" >> /tmp/$ORACLE_SID.par
fi
else
echo "SCHEMAS=$oUSER" >> /tmp/$ORACLE_SID.par
fi
echo "DUMPFILE=$WORACLE_SID.$DOYB.$oUSER.$DIAHORA.$DIA_SEMANA.%U.dmp" >> /tmp/$ORACLE_SID.par
echo " LOGFILE=$WORACLE_SID.$DOYB.$oUSER.$DIAHORA.$DIA_SEMANA.00.log" >> /tmp/$ORACLE_SID.par
echo "FILESIZE=8G" >> /tmp/$ORACLE_SID.par
echo "DIRECTORY=DPDUMP_FULL" >> /tmp/$ORACLE_SID.par
echo "CONSISTENT=Y" >> /tmp/$ORACLE_SID.par
echo "JOB_NAME=$ORACLE_SID""_DATA_PUMP_JOB" >> /tmp/$ORACLE_SID.par
echo "EXCLUDE=STATISTICS" >> /tmp/$ORACLE_SID.par
expdp \"/ as sysdba\" parfile=/tmp/$ORACLE_SID.par
status=$?
if [ $status -gt 0 ] ; then
mailx -s "$CLIENTE-$PROPOSTA : $HOSTNAME-$ORACLE_SID-Rotina Dump, FALHOU" $CMAI < $WRKDIR/$ORACLE_SID.$DOYB.$DIAHORA.00.log
else
sleep 2
echo Compactando Dump : $WRKDIR/$DMPFILE
cd $WRKDIR/
tar -cvzf $WRKDIR/$DMPFILE $WORACLE_SID.$DOYB.$oUSER.$DIAHORA*.log $WORACLE_SID.$DOYB.$oUSER.$DIAHORA*.dmp
sleep 2
if [ -f "$WRKDIR/$DMPFILE" ] ; then
rm $WRKDIR/$WORACLE_SID.$DOYB.$oUSER.$DIAHORA*.log $WRKDIR/$WORACLE_SID.$DOYB.$oUSER.$DIAHORA*.dmp /tmp/$ORACLE_SID.par
fi
fi
echo
if [ -f "/tmp/backup_dpmp.log" ] ; then
rm /tmp/backup_dpmp.log
fi
done