diff --git a/mysql/backup.pl b/mysql/backup.pl index b69b0e718..d2b3b7e86 100755 --- a/mysql/backup.pl +++ b/mysql/backup.pl @@ -16,15 +16,9 @@ else { $cmode = 0; } -if ($cmode) { - # Run and check before-backup command (for all DBs) - $bok = &execute_before(undef, STDOUT, 0, $config{'backup_'}, undef); - if (!$bok) { - $failure = "Before-backup command failed!\n"; - $ex = 1; - goto EMAIL; - } - } +$ex = 0; +$email = $config{'backup_email_'.($all ? '' : $dbs[0])}; +$notify = $config{'backup_notify_'.($all ? '' : $dbs[0])}; # Check if MySQL is running ($r, $out) = &is_mysql_running(); @@ -35,9 +29,16 @@ if (!$r) { goto EMAIL; } -$ex = 0; -$email = $config{'backup_email_'.($all ? '' : $dbs[0])}; -$notify = $config{'backup_notify_'.($all ? '' : $dbs[0])}; +if ($cmode) { + # Run and check before-backup command (for all DBs) + $bok = &execute_before(undef, STDOUT, 0, $config{'backup_'}, undef); + if (!$bok) { + $failure = "Before-backup command failed!\n"; + $ex = 1; + goto EMAIL; + } + } + foreach $db (@dbs) { $sf = $all ? "" : $db; if ($all) { diff --git a/mysql/mysql-lib.pl b/mysql/mysql-lib.pl index 8c5cf1e90..735f8b96a 100755 --- a/mysql/mysql-lib.pl +++ b/mysql/mysql-lib.pl @@ -119,7 +119,7 @@ sub is_mysql_running if ($driver_handle && !$config{'nodbi'}) { local $main::error_must_die = 1; local ($data, $rv); - eval { $data = &execute_sql_safe(undef, "select version()") }; + eval { $data = &execute_sql_safe(undef, "select version()"); }; local $err = $@; $err =~ s/\s+at\s+\S+\s+line.*$//; if ($@ =~ /denied|password/i) { @@ -137,7 +137,8 @@ if ($driver_handle && !$config{'nodbi'}) { } # Fall back to mysqladmin command -local $out = `"$config{'mysqladmin'}" $authstr status 2>&1`; +local $out = &backquote_command( + "\"$config{'mysqladmin'}\" $authstr status 2>&1"); local $rv = $out =~ /uptime/i ? 1 : $out =~ /denied|password/i ? -1 : 0; $out =~ s/^.*\Q$config{'mysqladmin'}\E\s*:\s*//;