@@ -0,0 +1,437 @@
+--- automysqlbackup-2.5.1-01.sh.orig 2011-01-23 20:19:08.121944594 +0100
++++ automysqlbackup-2.5.1-01.sh 2011-01-23 20:23:29.453281536 +0100
+@@ -36,19 +36,19 @@
+ # (copy a new version to its location) without the need for editing it.
+ ### START CFG ###
+ # Username to access the MySQL server e.g. dbuser
+- USERNAME=debian
++ USERNAME=`echo ${USERNAME:=dbuser}`
+
+ # Password to access the MySQL server e.g. password
+- PASSWORD=
++ PASSWORD=`echo ${PASSWORD:=password}`
+
+ # Host name (or IP address) of MySQL server e.g localhost
+- DBHOST=localhost
++ DBHOST=`echo ${DBHOST:=localhost}`
+
+ # List of DBNAMES for Daily/Weekly Backup e.g. "DB1 DB2 DB3"
+- DBNAMES="all"
++ DBNAMES=`echo ${DBNAMES:="DB1 DB2 DB3"}`
+
+ # Backup directory location e.g /backups
+- BACKUPDIR="/srv/backup/db"
++ BACKUPDIR=`echo ${BACKUPDIR:="/backup/mysql/${DBHOST}"}`
+
+ # Mail setup
+ # What would you like to be mailed to you?
+@@ -64,6 +64,8 @@
+ # Email Address to send mail to? (user@domain.com)
+ MAILADDR="maintenance@example.com"
+
++ # Email Address to send mail from? (root@host.tld)
++ FROMADDR="automysqlbackup@`hostname -f`"
+
+ # ============================================================
+ # === ADVANCED OPTIONS ( Read the doc's below for details )===
+@@ -73,10 +75,10 @@
+ MDBNAMES="${DBNAMES}"
+
+ # List of DBNAMES to EXLUCDE if DBNAMES are set to all (must be in " quotes)
+- DBEXCLUDE=""
++ DBEXCLUDE=`echo ${DBEXCLUDE:=""}`
+
+ # Include CREATE DATABASE in backup?
+- CREATE_DATABASE=no
++ CREATE_DATABASE=yes
+
+ # Separate backup directory and file for each DB? (yes or no)
+ SEPDIR=yes
+@@ -85,8 +87,11 @@
+ DOWEEKLY=6
+
+ # Choose Compression type. (gzip or bzip2)
+- COMP=gzip
+-
++ COMP=bzip2
++
++ # Use pipe compress
++ PIPECOMP=yes
++
+ # Compress communications between backup server and MySQL server?
+ COMMCOMP=no
+
+@@ -98,7 +103,10 @@
+
+ # For connections to localhost. Sometimes the Unix socket file must be specified.
+ SOCKET=
+-
++
++ # Backup databases per table work if SEPDIR set to `yes'
++ PERTABLE=yes
++
+ # Command to run before backups (uncomment to use)
+ #PREBACKUP="/etc/mysql-backup-pre"
+
+@@ -508,13 +516,51 @@
+ return $?
+ }
+
++dbdump_comp () {
++if [ "$COMP" = "gzip" ]; then
++ ${ECHO} Backup Information for "${1}.gz"
++ SUFFIX=".gz"
++ ${MYSQLDUMP} --user=${USERNAME} --password=${PASSWORD} --host=${DBHOST} ${OPT} ${1} | ${GZIP} > ${2}${SUFFIX}
++ ${GZIP} -l "$1.gz"
++elif [ "$COMP" = "bzip2" ]; then
++ ${ECHO} Compression information for "${1}.bz2"
++ SUFFIX=".bz2"
++ ${MYSQLDUMP} --user=${USERNAME} --password=${PASSWORD} --host=${DBHOST} ${OPT} ${1} | ${BZIP2} -v 2>&1 > ${2}${SUFFIX}
++else
++ ${ECHO} "No compression option set, check advanced settings"
++fi
++return $?
++}
++
++dbdump_table () {
++${MYSQLDUMP} --user=${USERNAME} --password=${PASSWORD} --host=${DBHOST} ${OPT} ${1} ${2} > ${3}
++return $?
++}
++
++dbdump_table_comp () {
++if [ "${COMP}" = "gzip" ]; then
++ echo
++ echo Backup Information for "$3.gz"
++ SUFFIX=".gz"
++ ${MYSQLDUMP} --user=${USERNAME} --password=${PASSWORD} --host=${DBHOST} ${OPT} ${1} ${2} | ${GZIP} > ${3}${SUFFIX}
++ ${GZIP} -l "${3}.gz"
++elif [ "${COMP}" = "bzip2" ]; then
++ echo Compression information for "${3}.bz2"
++ SUFFIX=".bz2"
++ ${MYSQLDUMP} --user=${USERNAME} --password=${PASSWORD} --host=${DBHOST} ${OPT} ${1} ${2} | ${BZIP2} -v 2>&1 > ${3}${SUFFIX}
++else
++ echo "No compression option set, check advanced settings"
++fi
++return $?
++}
++
+ # Compression function plus latest copy
+ SUFFIX=""
+ compression () {
+ if [ "${COMP}" = "gzip" ]; then
+ ${GZIP} -f "${1}"
+ ${ECHO}
+- ${ECHO} Backup Information for "${1}"
++ ${ECHO} Backup Information for "${1}.gz"
+ ${GZIP} -l "${1}.gz"
+ SUFFIX=".gz"
+ elif [ "${COMP}" = "bzip2" ]; then
+@@ -547,6 +593,8 @@
+ if [ "${SEPDIR}" = "yes" ]; then # Check if CREATE DATABSE should be included in Dump
+ if [ "${CREATE_DATABASE}" = "no" ]; then
+ OPT="${OPT} --no-create-db"
++ elif [ "${PERTABLE}" = "yes" ]; then
++ OPT="${OPT} --no-create-db"
+ else
+ OPT="${OPT} --databases"
+ fi
+@@ -596,19 +644,43 @@
+ # Prepare ${DB} for using
+ MDB="`${ECHO} ${MDB} | ${SED} 's/%/ /g'`"
+
+- if [ ! -e "${BACKUPDIR}/monthly/${MDB}" ] # Check Monthly DB Directory exists.
+- then
+- mkdir -p "${BACKUPDIR}/monthly/${MDB}"
++ if [ "${PERTABLE}" = "yes" ]; # Check backup per table
++ then # Start Monthly DB backup per table
++ echo Monthly Backup of ${MDB} per table...
++ TABLES="`${MYSQL} --user=${USERNAME} --password=${PASSWORD} --host=${DBHOST} --batch --skip-column-names -e "show tables" ${MDB} | sed 's/ /%/g'`"
++ for TABLE in $TABLES
++ do
++ if [ ! -e "${BACKUPDIR}/monthly/${MDB}_pertable/${MDB}_pertable_${DATE}.${M}.${MDB}" ] # Check Monthly DB per table Directory exists.
++ then
++ mkdir -p "${BACKUPDIR}/monthly/${MDB}_pertable/${MDB}_pertable_${DATE}.${M}.${MDB}"
++ fi
++ if [ "${PIPECOMP}" = "yes" ]; then
++ dbdump_table_comp "${MDB}" "${TABLE}" "${BACKUPDIR}/monthly/${MDB}_pertable/${MDB}_pertable_${DATE}.${M}.${MDB}/${TABLE}.sql"
++ BACKUPFILES="${BACKUPFILES} ${BACKUPDIR}/monthly/${MDB}_pertable/${MDB}_pertable_${DATE}.${M}.${MDB}/${TABLE}.sql${SUFFIX}"
++ else
++ dbdump_table "${MDB}" "${TABLE}" "${BACKUPDIR}/monthly/${MDB}_pertable/${MDB}_pertable_${DATE}.${M}.${MDB}/${TABLE}.sql"
++ compression "${BACKUPDIR}/monthly/${MDB}_pertable/${MDB}_pertable_${DATE}.${M}.${MDB}/${TABLE}.sql"
++ BACKUPFILES="${BACKUPFILES} ${BACKUPDIR}/monthly/${MDB}_pertable/${MDB}_pertable_${DATE}.${M}.${MDB}/${TABLE}.sql${SUFFIX}"
++ fi
++ done
++ echo ----------------------------------------------------------------------
++ else # Start Monthly DB full
++ if [ ! -e "${BACKUPDIR}/monthly/${MDB}" ] # Check Monthly DB Directory exists.
++ then
++ mkdir -p "${BACKUPDIR}/monthly/${MDB}"
++ fi
++
++ echo Monthly Backup of ${MDB}...
++ if [ "${PIPECOMP}" = "yes" ]; then
++ dbdump_comp "${MDB}" "${BACKUPDIR}/monthly/${MDB}/${MDB}_${DATE}.${M}.${MDB}.sql"
++ BACKUPFILES="${BACKUPFILES} ${BACKUPDIR}/monthly/${MDB}/${MDB}_${DATE}.${M}.${MDB}.sql${SUFFIX}"
++ else
++ dbdump "${MDB}" "${BACKUPDIR}/monthly/${MDB}/${MDB}_${DATE}.${M}.${MDB}.sql"
++ compression "${BACKUPDIR}/monthly/${MDB}/${MDB}_${DATE}.${M}.${MDB}.sql"
++ BACKUPFILES="${BACKUPFILES} ${BACKUPDIR}/monthly/${MDB}/${MDB}_${DATE}.${M}.${MDB}.sql${SUFFIX}"
++ fi
++ echo ----------------------------------------------------------------------
+ fi
+- ${ECHO} Monthly Backup of ${MDB}...
+- dbdump "${MDB}" "${BACKUPDIR}/monthly/${MDB}/${MDB}_${DATE}.${M}.${MDB}.sql"
+- [ $? -eq 0 ] && {
+- ${ECHO} "Rotating 5 month backups for ${MDB}"
+- ${FIND} "${BACKUPDIR}/monthly/${MDB}" -mtime +150 -type f -exec ${RM} -v {} \;
+- }
+- compression "${BACKUPDIR}/monthly/${MDB}/${MDB}_${DATE}.${M}.${MDB}.sql"
+- BACKUPFILES="${BACKUPFILES} ${BACKUPDIR}/monthly/${MDB}/${MDB}_${DATE}.${M}.${MDB}.sql${SUFFIX}"
+- ${ECHO} ----------------------------------------------------------------------
+ done
+ fi
+
+@@ -618,40 +690,127 @@
+ DB="`${ECHO} ${DB} | ${SED} 's/%/ /g'`"
+
+ # Create Seperate directory for each DB
+- if [ ! -e "${BACKUPDIR}/daily/${DB}" ] # Check Daily DB Directory exists.
++ if [ "${PERTABLE}" = "yes" ];
|