FAQ | This is a LIVE service | Changelog

Commit 40f64d5c authored by Dr Adam Thorn's avatar Dr Adam Thorn
Browse files

Improve check of whether mysql is(/should be) running in default prepare script

We think the intention of the old version of this block is

"if mysql is running, dump the databases".

The check has been buggy for a long long time: it reads the contents
of my.cnf ... which nowadays just has some !includedir directives.
This lead to setting

SOCKET=""

and, it turns out, [ -S "" ] returns true.

The main intention of this part of the prepare script is to backup
vaguely normal machines running a simple mysql database, such as
small group webservers. We thus don't need to consider every
eventuality.
parent b67e2b82
......@@ -74,9 +74,18 @@ which rsync >/dev/null 2>&1 || apt-get install rsync
debconf-get-selections >/var/adm/backup/debconf
# Dump MySQL, if the root user has access
if [ -f /etc/mysql/my.cnf ] ; then
SOCKET=`awk ' BEGIN {FLAG=0} (\$0 ~ /^\[/) {FLAG=0} (\$0 ~ /^\[mysqld\]/) {FLAG=1} (\$1=="socket" && FLAG==1) { print \$3 ; } ' </etc/mysql/my.cnf`
[ -S \$SOCKET ] && which mysqldump >/dev/null 2>&1 && mysqldump --defaults-file=/etc/mysql/debian.cnf --all-databases >/var/adm/backup/mysql
set +e
systemctl is-enabled mysql --quiet 2>/dev/null
MYSQL_ENABLED=\$?
set -e
if [ \$MYSQL_ENABLED -eq 0 ] ; then
if [ -f /root/.my.cnf ] ; then
DEFAULTS_FILE=/root/.my.cnf
else
DEFAULTS_FILE=/etc/mysql/debian.cnf
fi
mysqldump --defaults-file=\$DEFAULTS_FILE --all-databases >/var/adm/backup/mysql
fi
# Ignore exit status of this command
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment