X-Git-Url: https://git.stderr.nl/gitweb?a=blobdiff_plain;f=handlers%2Fmysql;h=7ca9ab64ecbc2dc6a17839ecad79e5cfa21a5279;hb=c8efb40b7febbdd2aee03996938e6d8c63c06377;hp=6fd50562998ed648ea91cfbc2e105e6befecc0fb;hpb=3b59f10fd327bcfe92285db302ab52e23c407eca;p=matthijs%2Fupstream%2Fbackupninja.git diff --git a/handlers/mysql b/handlers/mysql index 6fd5056..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 # @@ -35,7 +36,7 @@ fi # If needed, make sure that the specified vserver exists and is running. if [ $usevserver ] then - info "Examining vserver '$vsname'" + debug "Examining vserver '$vsname'" # does it exist ? vroot="$VROOTDIR/$vsname" [ -d $vroot ] || fatal "vserver '$vsname' does not exist at '$vroot'" @@ -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" - info "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 - info "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 @@ -115,19 +90,21 @@ fi # specify the password on the command line. defaultsfile="" + if [ "$dbusername" != "" -a "$dbpassword" != "" ] then if [ $usevserver ] then - home=`$VSERVER $vsname exec getent passwd "root" | awk -F: '{print $6}'` - home="$vroot$home" - info "Home set to: $home" + vhome=`$VSERVER $vsname exec getent passwd "root" | awk -F: '{print $6}'` + home="$vroot$vhome" else home=`getent passwd "root" | awk -F: '{print $6}'` - info "Home set to: $home" fi + [ -d $home ] || fatal "Can't find root's home directory ($home)." + mycnf="$home/.my.cnf" + if [ -f $mycnf ] then # rename temporarily @@ -135,27 +112,64 @@ then debug "mv $mycnf $tmpcnf" mv $mycnf $tmpcnf fi + oldmask=`umask` umask 077 cat > $mycnf <