Package: automysqlbackup
Version: 2.6+debian.4-4
Severity: normal
Tags: patch

Thomas,

mariadb-server NEWS.Debian.gz says:
   - Referencing the /etc/mysql/debian.cnf file is not advised anymore. It will
     be deprecated in a future Debian release and has been obsolete anyway for
     several years now since MariaDB in Debian introduced Unix socket
     authentication for the root account in 2015.
   ...
 -- Otto Kekäläinen <o...@debian.org>  Thu, 17 Sep 2020 14:37:47 +0300

Below is a patch which removes references to /etc/mysql/debian.cnf .
In addition, the changed lines:
  * all satisfy ShellCheck
  * sometimes improve logic

By the way, I believe that /usr/sbin/automysqlbackup has no bashisms
and should change from "#!/bin/bash" to "#!/bin/sh" (dash).

Thank you!
Daniel Lewart
Urbana, Illinois
---
diff -ru a/etc/default/automysqlbackup b/etc/default/automysqlbackup
--- a/etc/default/automysqlbackup       2021-08-30 09:50:19.000000000 -0500
+++ b/etc/default/automysqlbackup       2023-12-15 00:00:00.000000000 -0600
@@ -1,13 +1,13 @@
 # By default, the Debian version of automysqlbackup will use:
-# mysqldump --defaults-file=/etc/mysql/debian.cnf
+# mysqldump
 # but you might want to overwrite with a specific user & pass.
 # To do this, simply edit bellow.
 
 # Username to access the MySQL server e.g. dbuser
-#USERNAME=`grep user /etc/mysql/debian.cnf | tail -n 1 | cut -d"=" -f2 | awk 
'{print $1}'`
+#USERNAME=dbuser
 
 # Username to access the MySQL server e.g. password
-#PASSWORD=`grep password /etc/mysql/debian.cnf | tail -n 1 | cut -d"=" -f2 | 
awk '{print $1}'`
+#PASSWORD=password
 
 # Host name (or IP address) of MySQL server e.g localhost
 DBHOST=localhost
@@ -20,9 +20,10 @@
 # and write your own.
 # The following is a quick hack that will find the names of the databases by
 # reading the mysql folder content. Feel free to replace by something else.
-# DBNAMES=`find /var/lib/mysql -mindepth 1 -maxdepth 1 -type d | cut -d'/' -f5 
| grep -v ^mysql\$ | tr \\\r\\\n ,\ `
+# DBNAMES=$(find /var/lib/mysql -mindepth 1 -maxdepth 1 -type d | cut -d/ -f5 
| grep -Ev '^(mysql|performance_schema)$' | tr '\n' ' ' | sed 's/ $//')
+
 # This one does a list of dbs using a MySQL statement.
-DBNAMES=`mysql --defaults-file=/etc/mysql/debian.cnf --execute="SHOW 
DATABASES" | awk '{print $1}' | grep -v ^Database$ | grep -v ^mysql$ | grep -v 
^performance_schema$ | grep -v ^information_schema$ | tr \\\r\\\n ,\ `
+DBNAMES=$(mysql -BNe 'SHOW DATABASES' | grep -Ev 
'^(information_schema|mysql|performance_schema)$' | tr '\n' ' ' | sed 's/ $//')
 
 # Backup directory location e.g /backups
 # Folders inside this one will be created (daily, weekly, etc.), and the
diff -ru a/usr/sbin/automysqlbackup b/usr/sbin/automysqlbackup
--- a/usr/sbin/automysqlbackup  2021-08-30 09:50:19.000000000 -0500
+++ b/usr/sbin/automysqlbackup  2023-12-15 00:00:00.000000000 -0600
@@ -446,7 +446,7 @@
                        touch "$2.gz"
                        chmod 600 "$2.gz"
                        if [ -z "${USERNAME}" -o -z "${PASSWORD}" ] ; then
-                               mysqldump --defaults-file=/etc/mysql/debian.cnf 
$NEWOPT $1 | gzip -f > "$2.gz"
+                               mysqldump "${NEWOPT}" "$1" | gzip -f > "$2.gz"
                        else
                                mysqldump --user=$USERNAME --password=$PASSWORD 
--host=$DBHOST $NEWOPT $1  | gzip -f > "$2.gz"
                        fi
@@ -455,7 +455,7 @@
                        touch "$2.bz2"
                         chmod 600 "$2.bz2"
                        if [ -z "${USERNAME}" -o -z "${PASSWORD}" ] ; then
-                                mysqldump 
--defaults-file=/etc/mysql/debian.cnf $NEWOPT $1 | gzip -f > "$2.bz2"
+                                mysqldump "${NEWOPT}" "$1" | gzip -f > "$2.bz2"
                         else
                                 mysqldump --user=$USERNAME 
--password=$PASSWORD --host=$DBHOST $NEWOPT $1  | gzip -f > "$2.bz2"
                         fi
@@ -464,7 +464,7 @@
                touch $2
                chmod 600 $2
                if [ -z "${USERNAME}" -o -z "${PASSWORD}" ] ; then
-                       mysqldump --defaults-file=/etc/mysql/debian.cnf $NEWOPT 
$1 > $2
+                       mysqldump "${NEWOPT}" "$1" > "$2"
                        compression $2
                else
                        mysqldump --user=$USERNAME --password=$PASSWORD 
--host=$DBHOST $NEWOPT $1 > $2
@@ -532,7 +532,7 @@
 # If backing up all DBs on the server
 if [ "$DBNAMES" = "all" ]; then
        if [ -z "${USERNAME}" -o -z "${PASSWORD}" ] ; then
-        DBNAMES="`mysql --defaults-file=/etc/mysql/debian.cnf --batch 
--skip-column-names -e "show databases"| sed 's/ /%/g'`"
+        DBNAMES="$(mysql --batch --skip-column-names -e "SHOW DATABASES" | tr 
' ' '%')"
        else
         DBNAMES="`mysql --user=$USERNAME --password=$PASSWORD --host=$DBHOST 
--batch --skip-column-names -e "show databases"| sed 's/ /%/g'`"
        fi

Reply via email to