Improved the error reporting for the backup (in case mysqldump fails with a single error, then the error is displayed directly)

SVN:trunk[2824]
This commit is contained in:
Romain Quetiez
2013-08-19 15:15:53 +00:00
parent b2e4cf2c09
commit d8c9044e15

View File

@@ -207,7 +207,7 @@ class DBBackup
}
// Delete the file created by tempnam() so that the spawned process can write into it (Windows/IIS)
unlink($sBackupFileName);
$sCommand = "$sMySQLDump --opt --default-character-set=utf8 --add-drop-database --single-transaction --host=$sHost $sPortOption --user=$sUser --password=$sPwd --result-file=$sTmpFileName $sDBName $sTables 2>&1";
$sCommand = "$sMySQLDump --opt --default-character-set=utf8 --add-drop-database --single-transaction --host=$sHost $sPortOption --user=xx$sUser --password=$sPwd --result-file=$sTmpFileName $sDBName $sTables 2>&1";
$sCommandDisplay = "$sMySQLDump --opt --default-character-set=utf8 --add-drop-database --single-transaction --host=$sHost $sPortOption --user=xxxxx --password=xxxxx --result-file=$sTmpFileName $sDBName $sTables";
// Now run the command for real
@@ -221,8 +221,20 @@ class DBBackup
}
if ($iRetCode != 0)
{
$this->LogError("retcode=".$iRetCode."\n");
throw new BackupException("Failed to execute mysqldump. Return code: $iRetCode. Check the log file '".realpath(APPROOT.'/log/setup.log')."' for more information.");
$this->LogError("Failed to execute: $sCommandDisplay. The command returned:$iRetCode");
foreach($aOutput as $sLine)
{
$this->LogError("mysqldump said: $sLine");
}
if (count($aOutput) == 1)
{
$sMoreInfo = trim($aOutput[0]);
}
else
{
$sMoreInfo = "Check the log files '".realpath(APPROOT.'/log/setup.log or error.log')."' for more information.";
}
throw new BackupException("Failed to execute mysqldump: ".$sMoreInfo);
}
}