additional error handling for backup/restore (#2187)
prerequisite: - add at least one backup path to the Advanced->defaults - do NOT install rar archive/de-archive programs test case #1 - go to backup screen and download backups as rar test case #2 - go to backup screen and upload a RAR file expected result: - get a sign that an error occurs actual result: - not clear if it failed, or why fix: added error message. And you will get the top-bar warning in red on error instead of in green. note: cut-pasted from google translate for "extraction failed" part of message-restore_failed_extract
This commit is contained in:
+22
-7
@@ -58,7 +58,9 @@ else {
|
||||
if (isset($_SESSION['backup']['path'])) foreach ($_SESSION['backup']['path'] as $value) {
|
||||
$cmd .= $value.' ';
|
||||
}
|
||||
exec($cmd);
|
||||
$cmd .= " 2>&1";
|
||||
exec($cmd, $response, $restore_errlevel);
|
||||
$response_txt = "<br>" . implode("<br>", $response);
|
||||
|
||||
//download the file
|
||||
session_cache_limiter('public');
|
||||
@@ -79,7 +81,8 @@ else {
|
||||
}
|
||||
else {
|
||||
//set response message
|
||||
$_SESSION["message"] = $text['message-backup_failed_format'];
|
||||
$_SESSION["message"] = $text['message-backup_failed_format'] . $response_txt;
|
||||
$_SESSION['message_mood'] = 'negative';
|
||||
header("Location: ".$_SERVER['PHP_SELF']);
|
||||
exit;
|
||||
}
|
||||
@@ -87,6 +90,7 @@ else {
|
||||
else {
|
||||
//set response message
|
||||
$_SESSION["message"] = $text['message-backup_failed_paths'];
|
||||
$_SESSION['message_mood'] = 'negative';
|
||||
header("Location: ".$_SERVER['PHP_SELF']);
|
||||
exit;
|
||||
}
|
||||
@@ -123,20 +127,31 @@ else {
|
||||
if (!$valid_format) {
|
||||
@unlink($backup_path.'/'.$backup_file);
|
||||
$_SESSION["message"] = $text['message-restore_failed_format'];
|
||||
$_SESSION['message_mood'] = 'negative';
|
||||
header("Location: ".$_SERVER['PHP_SELF']);
|
||||
exit;
|
||||
}
|
||||
else {
|
||||
exec($cmd);
|
||||
//set response message
|
||||
$_SESSION["message"] = $text['message-restore_completed'];
|
||||
header("Location: ".$_SERVER['PHP_SELF']);
|
||||
exit;
|
||||
$cmd .= ' 2>&1';
|
||||
exec($cmd, $response, $restore_errlevel);
|
||||
$response_txt = "<br>" . implode("<br>", $response);
|
||||
if ($restore_errlevel == 0) {
|
||||
//set response message
|
||||
$_SESSION["message"] = $text['message-restore_completed'];
|
||||
header("Location: ".$_SERVER['PHP_SELF']);
|
||||
exit;
|
||||
} else {
|
||||
$_SESSION["message"] = $text['message-restore_failed_extract'] . $response_txt;
|
||||
$_SESSION['message_mood'] = 'negative';
|
||||
header("Location: ".$_SERVER['PHP_SELF']);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
//set response message
|
||||
$_SESSION["message"] = $text['message-restore_failed_upload'];
|
||||
$_SESSION['message_mood'] = 'negative';
|
||||
header("Location: ".$_SERVER['PHP_SELF']);
|
||||
exit;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user