X-Git-Url: https://git.stderr.nl/gitweb?a=blobdiff_plain;f=handlers%2Fmysql;h=a19509bf062545b0192b42db6974d49fa9a5d060;hb=b5130c49410c6c1300b9c8f6246a61c4d1e66004;hp=0ff9884987adbb2189c084d6fb48e86e66b1ce49;hpb=b756a86db7bb96737b8a6f82934e5ab675b2811c;p=matthijs%2Fupstream%2Fbackupninja.git diff --git a/handlers/mysql b/handlers/mysql index 0ff9884..a19509b 100644 --- a/handlers/mysql +++ b/handlers/mysql @@ -24,7 +24,7 @@ getconf configfile /etc/mysql/debian.cnf local usevserver=no local vroot if [ $vservers_are_available = yes ]; then - if [ ! -z "$vsname" ]; then + if [ -n "$vsname" ]; then # does it exist ? if ! vservers_exist "$vsname" ; then fatal "The vserver given in vsname ($vsname) does not exist." @@ -160,7 +160,7 @@ else 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" + defaultsfile="--defaults-file=$userhome/.my.cnf" debug "using $defaultsfile" fi @@ -179,7 +179,7 @@ then else execstr="$MYSQLHOTCOPY --quiet --allowold --regexp /.\*/./.\*/ $hotdir" fi - debug "su $user -c '$execstr'" + debug "su $user -c \"$execstr\"" if [ ! $test ] then output=`su $user -c "$execstr" 2>&1` @@ -202,7 +202,7 @@ then else execstr="$MYSQLHOTCOPY --allowold $db $hotdir" fi - debug "su $user -c '$execstr'" + debug 'su $user -c \"$execstr\"' if [ ! $test ] then output=`su $user -c "$execstr" 2>&1` @@ -230,7 +230,7 @@ then then if [ $usevserver = yes ] then - debug "echo show databases | $VSERVER $vsname exec su $user -c $MYSQL $defaultsfile | grep -v Database" + 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` if [ $? -ne 0 ] then @@ -249,11 +249,19 @@ fi do if [ $usevserver = yes ] then - execstr="$VSERVER $vsname exec $MYSQLDUMP $defaultsfile --lock-tables --complete-insert --add-drop-table --quick --quote-names $ignore $db > $vroot$dumpdir/${db}.sql" + if [ "$compress" == "yes" ]; then + execstr="$VSERVER $vsname exec $MYSQLDUMP $defaultsfile --lock-tables --complete-insert --add-drop-table --quick --quote-names $ignore $db | $GZIP > $vroot$dumpdir/${db}.sql.gz" + else + execstr="$VSERVER $vsname exec $MYSQLDUMP $defaultsfile --lock-tables --complete-insert --add-drop-table --quick --quote-names $ignore $db > $vroot$dumpdir/${db}.sql" + fi else - execstr="$MYSQLDUMP $defaultsfile --lock-tables --complete-insert --add-drop-table --quick --quote-names $ignore $db > $dumpdir/${db}.sql" + if [ "$compress" == "yes" ]; then + execstr="$MYSQLDUMP $defaultsfile --lock-tables --complete-insert --add-drop-table --quick --quote-names $ignore $db | $GZIP > $dumpdir/${db}.sql.gz" + else + execstr="$MYSQLDUMP $defaultsfile --lock-tables --complete-insert --add-drop-table --quick --quote-names $ignore $db > $dumpdir/${db}.sql" + fi fi - debug "su $user -c '$execstr'" + debug "su $user -c \"$execstr\"" if [ ! $test ] then output=`su $user -c "$execstr" 2>&1` @@ -268,16 +276,9 @@ fi fi fi done - - if [ "$compress" == "yes" ] - then - output=`$GZIP -f $vroot$dumpdir/*.sql 2>&1` - debug $output - fi -fi # clean up tmp config file -if [ "$dbusername" != "" ] +if [ "$dbusername" != "" -a "$dbpassword" != "" ] then ## clean up tmp config file debug "rm $mycnf"