From 7b556dc7db6232adae3b6ae3f58565c89083a087 Mon Sep 17 00:00:00 2001 From: Andrew Smith Date: Mon, 27 Jun 2011 14:08:36 +1000 Subject: [PATCH] Move the creation of the backup folders to before the attempt to create the log files because if the folder don't exist then no logs will be created on the first run. --- automysqlbackup.sh | 46 ++++++++++++++++++++++++---------------------- 1 file changed, 24 insertions(+), 22 deletions(-) diff --git a/automysqlbackup.sh b/automysqlbackup.sh index a2228bb..bc615fd 100755 --- a/automysqlbackup.sh +++ b/automysqlbackup.sh @@ -261,28 +261,6 @@ LOGERR=${BACKUPDIR}/ERRORS_${DBHOST}-`${DATEC} +%N`.log # Logfile Name BACKUPFILES="" OPT="--quote-names --opt" # OPT string for use with mysqldump ( see man mysqldump ) -# IO redirection for logging. -touch ${LOGFILE} -exec 6>&1 # Link file descriptor #6 with stdout. - # Saves stdout. -exec > ${LOGFILE} # stdout replaced with file ${LOGFILE}. -touch ${LOGERR} -exec 7>&2 # Link file descriptor #7 with stderr. - # Saves stderr. -exec 2> ${LOGERR} # stderr replaced with file ${LOGERR}. - -# Add --compress mysqldump option to ${OPT} -if [ "${COMMCOMP}" = "yes" ]; - then - OPT="${OPT} --compress" - fi - -# Add --max_allowed_packet=... mysqldump option to ${OPT} -if [ "${MAX_ALLOWED_PACKET}" ]; - then - OPT="${OPT} --max_allowed_packet=${MAX_ALLOWED_PACKET}" - fi - # Create required directories if [ ! -e "${BACKUPDIR}" ] # Check Backup Directory exists. then @@ -314,6 +292,30 @@ eval ${RM} -fv "${BACKUPDIR}/latest/*" fi + +# IO redirection for logging. +touch ${LOGFILE} +exec 6>&1 # Link file descriptor #6 with stdout. + # Saves stdout. +exec > ${LOGFILE} # stdout replaced with file ${LOGFILE}. +touch ${LOGERR} +exec 7>&2 # Link file descriptor #7 with stderr. + # Saves stderr. +exec 2> ${LOGERR} # stderr replaced with file ${LOGERR}. + + +# Add --compress mysqldump option to ${OPT} +if [ "${COMMCOMP}" = "yes" ]; + then + OPT="${OPT} --compress" + fi + +# Add --max_allowed_packet=... mysqldump option to ${OPT} +if [ "${MAX_ALLOWED_PACKET}" ]; + then + OPT="${OPT} --max_allowed_packet=${MAX_ALLOWED_PACKET}" + fi + # Functions # Database dump function