|
@@ -1,7 +1,7 @@
#!/bin/bash
#
# MySQL Backup Script
-# VER. 2.6.4 - http://sourceforge.net/projects/automysqlbackup/
+# VER. 2.6.5 - http://sourceforge.net/projects/automysqlbackup/
# Copyright (c) 2002-2003 wipe_out@lycos.co.uk
#
# This program is free software; you can redistribute it and/or modify
@@ -275,6 +275,8 @@
#=====================================================================
# Change Log
#=====================================================================
+# VER 2.6.5 - (2013-06-26)
+# - detect qmail sendmail binary (option -r is not supported in qmail)
# VER 2.6.4 - (2011-07-03)
# - per table excludes
# - mail command detection (option -r)
@@ -416,10 +418,23 @@
GREP="`${WHICH} grep`"
NAIL="`${WHICH} nail 2>/dev/null`"
MAIL="`${WHICH} mail 2>/dev/null`"
+SMBIN="`${WHICH} sendmail 2>/dev/null`"
+READLINK="`${WHICH} readlink 2>/dev/null`"
+
+function is_sendmail_qmail {
+ while [ -h ${SMBIN} ] ; do
+ SMBIN=`${READLINK} ${SMBIN}`
+ done
+ if [ -z "`echo ${SMBIN} | ${GREP} -i qmail`" ] ; then
+ echo 0
+ else
+ echo 1
+ fi
+}
if [ -z "${NAIL}" ] ; then
if [ -n "${MAIL}" ] ; then
- if [ -n "`${MAIL} -r 2>&1 | grep \"invalid option -- r\"`" ] ; then
+ if [ -n "`${MAIL} -r 2>&1 | grep \"invalid option -- r\"`" ]; then
# mail doesn't support -r
echo "No working 'mail' command found"
echo "Install nail which support -r option!"
@@ -429,8 +444,16 @@
fi
fi
else
- MAILCMD=${NAIL}
-fi
+ MAILCMD=${NAIL}
+fi
+
+# sendmail replacement of qmail does not support -r option
+if [ "`is_sendmail_qmail`" == "1" ] ; then
+ MAIL_BASE_CMD="${MAILCMD}"
+else
+ MAIL_BASE_CMD="${MAILCMD} -r ${FROMADDR}"
+fi
+
function get_debian_pw() {
if [ -r /etc/mysql/debian.cnf ]; then
eval $(${AWK} '
@@ -476,7 +499,7 @@
DOM=`${DATEC} +%d` # Date of the Month e.g. 27
M=`${DATEC} +%B` # Month e.g January
W=`${DATEC} +%V` # Week Number e.g 37
-VER=2.6.4 # Version Number
+VER=2.6.5 # Version Number
LOGFILE=${BACKUPDIR}/${DBHOST}-`${DATEC} +%N`.log # Logfile Name
LOGERR=${BACKUPDIR}/ERRORS_${DBHOST}-`${DATEC} +%N`.log # Logfile Name
BACKUPFILES=""
@@ -974,21 +997,21 @@
BACKUPFILES=`${ECHO} "${BACKUPFILES}" | ${SED} -e "s# # -a #g"` #enable multiple attachments
mutt -s "${ERRORNOTE} MySQL Backup Log and SQL Files for ${HOST} - ${DATE}" ${BACKUPFILES} ${MAILADDR} < ${LOGFILE} #send via mutt
else
- ${CAT} "${LOGFILE}" | ${MAILCMD} -r ${FROMADDR} -s "WARNING! - MySQL Backup exceeds set maximum attachment size on ${HOST} - ${DATE}" ${MAILADDR}
+ ${CAT} "${LOGFILE}" | ${MAIL_BASE_CMD} -s "WARNING! - MySQL Backup exceeds set maximum attachment size on ${HOST} - ${DATE}" ${MAILADDR}
fi
elif [ "${MAILCONTENT}" = "log" ]
then
- ${CAT} "${LOGFILE}" | ${MAILCMD} -r ${FROMADDR} -s "MySQL Backup Log for ${HOST} - ${DATE}" ${MAILADDR}
+ ${CAT} "${LOGFILE}" | ${MAIL_BASE_CMD} -s "MySQL Backup Log for ${HOST} - ${DATE}" ${MAILADDR}
if [ -s "${LOGERR}" ]
then
- ${CAT} "${LOGERR}" | ${MAILCMD} -r ${FROMADDR} -s "ERRORS REPORTED: MySQL Backup error Log for ${HOST} - ${DATE}" ${MAILADDR}
+ ${CAT} "${LOGERR}" | ${MAIL_BASE_CMD} -s "ERRORS REPORTED: MySQL Backup error Log for ${HOST} - ${DATE}" ${MAILADDR}
fi
elif [ "${MAILCONTENT}" = "quiet" ]
then
if [ -s "${LOGERR}" ]
then
- ${CAT} "${LOGERR}" | ${MAILCMD} -r ${FROMADDR} -s "ERRORS REPORTED: MySQL Backup error Log for ${HOST} - ${DATE}" ${MAILADDR}
- ${CAT} "${LOGFILE}" | ${MAILCMD} -r ${FROMADDR} -s "MySQL Backup Log for ${HOST} - ${DATE}" ${MAILADDR}
+ ${CAT} "${LOGERR}" | ${MAIL_BASE_CMD} -s "ERRORS REPORTED: MySQL Backup error Log for ${HOST} - ${DATE}" ${MAILADDR}
+ ${CAT} "${LOGFILE}" | ${MAIL_BASE_CMD} -s "MySQL Backup Log for ${HOST} - ${DATE}" ${MAILADDR}
fi
else
if [ -s "${LOGERR}" ]
|