Update export_datapump.sh

This commit is contained in:
Yacine31
2023-09-25 20:55:40 +02:00
parent 43c992e118
commit bc11c4ea5e

View File

@@ -4,6 +4,7 @@
# 14/09/2011 : YOU - Creation
# 14/10/2015 : YOU - script générique pour toutes les bases
# 15/12/2022 : YOU - retention de 1 jour
# 25/09/2023 : YOU - simplification du passage des paramètres
#------------------------------------------------------------------------------
#------------------------------------------------------------------------------
# fonction init : c'est ici qu'il faut modifier toutes les variables liées
@@ -33,7 +34,7 @@ f_help() {
echo "
syntaxe : $0 -s ORACLE_SID
syntaxe : $0 ORACLE_SID
------
"
exit $1
@@ -44,22 +45,6 @@ exit $1
#------------ MAIN ----------------------
#----------------------------------------
unset ORACLE_SID
while getopts :s:h o
do
case $o in
s) ORACLE_SID=$OPTARG;
;;
h) f_help 0;
;;
*) f_help 2;
;;
\?) f_help 2;
;;
esac
done
[ "${ORACLE_SID}" ] || f_help 2;
#------------------------------------------------------------------------------
@@ -124,16 +109,13 @@ $ORACLE_HOME/bin/expdp \'/ as sysdba\' full=y directory=$DPDIR dumpfile=export_$
cd ${EXP_LOCATION}
tar cfz export_${ORACLE_SID}.tgz export_${ORACLE_SID}.{dmp,log} && rm -f export_${ORACLE_SID}.dmp
#------------------------------------------------------------------------------
# Mail si des erreurs dans le fichier de sauvegarde
#------------------------------------------------------------------------------
EXPDP_LOG_FILE=${EXP_LOCATION}/export_${ORACLE_SID}.log
ERR_COUNT=$(egrep "^EXP-[0-9]*|^ORA-[0-9]:" ${EXPDP_LOG_FILE} | wc -l)
SUBJECT="$(hostname)-${ORACLE_SID} : Export Datapump"
MSG=$(egrep "^EXP-[0-9]*|^ORA-[0-9]:" ${EXPDP_LOG_FILE})
if [ ${ERR_COUNT} -ne 0 ]; then
mutt -s $SUBJECT ${MAIL_RCPT} < ${EXPDP_LOG_FILE}
curl -H "t: Erreur expdp base ${ORACLE_SID} sur le serveur $(hostname)" -d "$MSG" -L https://ntfy.axiome.io/expdp
fi