X-Git-Url: https://git.stderr.nl/gitweb?a=blobdiff_plain;f=handlers%2Fmysql;h=7ca9ab64ecbc2dc6a17839ecad79e5cfa21a5279;hb=0d606253af6ecb8ede07b0991a1f295fb70e7e65;hp=408399d2e53d44b92bc249c054f232e93e494780;hpb=06edbbddc536c3c7e204e54ca7897d9614307fcd;p=matthijs%2Fupstream%2Fbackupninja.git diff --git a/handlers/mysql b/handlers/mysql index 408399d..7ca9ab6 100644 --- a/handlers/mysql +++ b/handlers/mysql @@ -1,3 +1,4 @@ +# -*- mode: sh; sh-basic-offset: 3; indent-tabs-mode: nil; -*- # # mysql handler script for backupninja # @@ -47,32 +48,6 @@ then fi fi -if [ "$user" == "" ]; then - userset=false; - user=root; -else - userset=true; - if [ $usevserver ] - then - userhome=`$VSERVER $vsname exec getent passwd "$user" | awk -F: '{print $6}'` - if [ $? -eq 2 ] - then - fatal "User $user not found in /etc/passwd" - fi - userhome="$vroot$userhome" - debug "User home set to: $userhome" - [ -f $userhome/.my.cnf ] || fatal "Can't find config file in $userhome/.my.cnf" - else - userhome=`getent passwd "$user" | awk -F: '{print $6}'` - if [ $? -eq 2 ] - then - fatal "User $user not found in /etc/passwd" - fi - debug "User home set to: $userhome" - [ -f $userhome/.my.cnf ] || fatal "Can't find config file in $userhome/.my.cnf" - fi -fi - ## Prepare ignore part of the command ## This only works for mysqldump at the moment @@ -170,6 +145,33 @@ elif [ "$userset" == "false" ]; then defaultsfile="--defaults-file=$configfile" fi +if [ "$user" == "" ]; then + userset=false; + user=root; +else + userset=true; + if [ $usevserver ] + then + vuserhome=`$VSERVER $vsname exec getent passwd "$user" | awk -F: '{print $6}'` + if [ $? -eq 2 ] + then + fatal "User $user not found in /etc/passwd" + fi + userhome="$vroot$vuserhome" + else + userhome=`getent passwd "$user" | awk -F: '{print $6}'` + if [ $? -eq 2 ] + then + fatal "User $user not found in /etc/passwd" + fi + fi + + debug "User home set to: $userhome" + [ -f $userhome/.my.cnf ] || fatal "Can't find config file in $userhome/.my.cnf" + defaultsfile="--defaults-file=$vuserhome/.my.cnf" + debug "using $defaultsfile" +fi + ####################################################################### ## HOT COPY @@ -180,7 +182,8 @@ then then if [ $usevserver ] then - execstr="$VSERVER $vsname exec $MYSQLHOTCOPY --quiet --allowold --regexp /.\*/./.\*/ $hotdir" + info "dbhost: $dbhost" + execstr="$VSERVER $vsname exec $MYSQLHOTCOPY -h $dbhost --quiet --allowold --regexp /.\*/./.\*/ $hotdir" else execstr="$MYSQLHOTCOPY --quiet --allowold --regexp /.\*/./.\*/ $hotdir" fi @@ -238,13 +241,13 @@ then databases=`echo 'show databases' | $VSERVER $vsname exec su $user -c "$MYSQL $defaultsfile" | grep -v Database` if [ $? -ne 0 ] then - fatal "Something unexpected happened, the defaults file may have gone missing or is corrupt" + fatal "Authentication problem, maybe user/password is wrong" fi else databases=`echo 'show databases' | su $user -c "$MYSQL $defaultsfile" | grep -v Database` if [ $? -ne 0 ] then - fatal "Something unexpected happened, the defaults file may have gone missing or is corrupt" + fatal "Authentication problem, maybe user/password is wrong" fi fi fi