The problem was to append the USERNAME and PASSWORD at the end of the file, while the file is evaluated as shellscript and contains some mysql
commands to list database names that already require a login.
It also seems to make strong assumentions that debian.cnf
is available and contains the needed credentials, by finding databases like this:
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 ,\ `
which would probably need parameters to use $USERNAME
and $PASSWORD
instead of the deprecated defaults file.
I know that old mysql/mariadb packages configured a maintenance user in debian.cnf
but a fresh install does not contain such a account and so the script already fails when trying to list the databases.
The configuration file already contains a commented out alternative that seems to work:
DBNAMES=`find /var/lib/mysql -mindepth 1 -maxdepth 1 -type d | cut -d'/' -f5 | grep -v ^mysql\$ | tr \\\r\\\n ,\ `
I must say, that both lines look a bit fragile to me. I am not sure if this won't break sometime and if the whole automysqlbackup script or at least its configuration may not be the most robust solution.