X-Git-Url: https://git.stderr.nl/gitweb?a=blobdiff_plain;f=handlers%2Fmysql.in;h=7ff194e924b1f6bf655d638efc24dc94bd948764;hb=ceb5689d506197ffb2269c6c64a8ea0802d55aba;hp=c80a36a3d95881ba0aa8b4f8ba5fd20ec3efce05;hpb=93ec0b499ed605dabf4188a8bd94c5262b4911ba;p=matthijs%2Fupstream%2Fbackupninja-vserver.git diff --git a/handlers/mysql.in b/handlers/mysql.in index c80a36a..7ff194e 100644 --- a/handlers/mysql.in +++ b/handlers/mysql.in @@ -40,6 +40,8 @@ if [ $vservers_are_available = yes ]; then else info "No vserver name specified, actions will be performed on the host." fi +else + [ -z "$vsname" ] || warning 'vservers support disabled in backupninja.conf, vsname configuration line will be ignored' fi ## Prepare ignore part of the command @@ -159,7 +161,11 @@ else debug "User home set to: $userhome" [ -f $userhome/.my.cnf ] || fatal "Can't find config file in $userhome/.my.cnf" - defaultsfile="--defaults-extra-file=$userhome/.my.cnf" + if [ $usevserver = yes ]; then + defaultsfile="--defaults-extra-file=$vuserhome/.my.cnf" + else + defaultsfile="--defaults-extra-file=$userhome/.my.cnf" + fi debug "using $defaultsfile" fi @@ -176,7 +182,7 @@ then info "dbhost: $dbhost" execstr="$VSERVER $vsname exec $MYSQLHOTCOPY -h $dbhost --quiet --allowold --regexp /.\*/./.\*/ $hotdir" else - execstr="$MYSQLHOTCOPY --quiet --allowold --regexp /.\*/./.\*/ $hotdir" + execstr="$MYSQLHOTCOPY -h $dbhost --quiet --allowold --regexp /.\*/./.\*/ $hotdir" fi debug "su $user -c \"$execstr\"" if [ ! $test ] @@ -197,9 +203,9 @@ then do if [ $usevserver = yes ] then - execstr="$VSERVER $vsname exec $MYSQLHOTCOPY --allowold $db $hotdir" + execstr="$VSERVER $vsname exec $MYSQLHOTCOPY -h $dbhost --allowold $db $hotdir" else - execstr="$MYSQLHOTCOPY --allowold $db $hotdir" + execstr="$MYSQLHOTCOPY -h $dbhost --allowold $db $hotdir" fi debug 'su $user -c \"$execstr\"' if [ ! $test ] @@ -229,8 +235,8 @@ then then if [ $usevserver = yes ] then - debug 'echo show databases | $VSERVER $vsname exec su $user -c \"$MYSQL $defaultsfile\" | grep -v Database' - databases=`echo 'show databases' | $VSERVER $vsname exec su $user -c "$MYSQL $defaultsfile" | grep -v Database` + debug "$VSERVER $vsname exec su $user -c \"$MYSQL $defaultsfile -N -B -e 'show databases'\" | sed 's/|//g;/\+----/d'" + databases=`$VSERVER $vsname exec su $user -c "$MYSQL $defaultsfile -N -B -e 'show databases'" | sed 's/|//g;/\+----/d'` if [ $? -ne 0 ] then fatal "Authentication problem, maybe user/password is wrong or mysqld is not running?"