From: Marcin Haba Date: Fri, 29 May 2020 05:57:40 +0000 (+0200) Subject: baculum: Request #2546 support for full restore when file records for backup job... X-Git-Tag: Release-9.6.4~19 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d0435d2fc28db11e149f5ad2633372cbb1f781eb;p=thirdparty%2Fbacula.git baculum: Request #2546 support for full restore when file records for backup job are pruned --- diff --git a/gui/baculum/protected/API/Lang/en/messages.mo b/gui/baculum/protected/API/Lang/en/messages.mo index 8b96c5981..87d3647b8 100644 Binary files a/gui/baculum/protected/API/Lang/en/messages.mo and b/gui/baculum/protected/API/Lang/en/messages.mo differ diff --git a/gui/baculum/protected/API/Lang/pl/messages.mo b/gui/baculum/protected/API/Lang/pl/messages.mo index 7f9e93b00..c0f969d35 100644 Binary files a/gui/baculum/protected/API/Lang/pl/messages.mo and b/gui/baculum/protected/API/Lang/pl/messages.mo differ diff --git a/gui/baculum/protected/API/Lang/pt/messages.mo b/gui/baculum/protected/API/Lang/pt/messages.mo index 4a69ac99f..896a7b04b 100644 Binary files a/gui/baculum/protected/API/Lang/pt/messages.mo and b/gui/baculum/protected/API/Lang/pt/messages.mo differ diff --git a/gui/baculum/protected/API/Pages/API/RestoreRun.php b/gui/baculum/protected/API/Pages/API/RestoreRun.php index dbf57440d..446c5975e 100644 --- a/gui/baculum/protected/API/Pages/API/RestoreRun.php +++ b/gui/baculum/protected/API/Pages/API/RestoreRun.php @@ -33,6 +33,7 @@ class RestoreRun extends BaculumAPIServer { public function create($params) { $misc = $this->getModule('misc'); + $jobid = property_exists($params, 'id') && $misc->isValidInteger($params->id) ? intval($params->id) : null; $client = null; if (property_exists($params, 'clientid')) { $clientid = intval($params->clientid); @@ -42,8 +43,17 @@ class RestoreRun extends BaculumAPIServer { $client = $params->client; } + $fileset = null; + if (property_exists($params, 'filesetid')) { + $filesetid = intval($params->filesetid); + $fileset_row = $this->getModule('fileset')->getFileSetById($filesetid); + $fileset = is_object($fileset_row) ? $fileset_row->fileset : null; + } elseif (property_exists($params, 'fileset') && $misc->isValidName($params->fileset)) { + $fileset = $params->fileset; + } + $rfile = property_exists($params, 'rpath') ? $params->rpath : null; - $priority = property_exists($params, 'priority') ? intval($params->priority) : 10; // default priority is set to 10 + $full = property_exists($params, 'full') && $misc->isValidInteger($params->full) ? (bool)$params->full : null; $where = property_exists($params, 'where') ? $params->where : null; $replace = property_exists($params, 'replace') ? $params->replace : null; @@ -74,7 +84,7 @@ class RestoreRun extends BaculumAPIServer { return; } - if(preg_match($misc::RPATH_PATTERN, $rfile) !== 1) { + if(!is_null($rfile) && preg_match($misc::RPATH_PATTERN, $rfile) !== 1) { $this->output = JobError::MSG_ERROR_INVALID_RPATH; $this->error = JobError::ERROR_INVALID_RPATH; return; @@ -92,16 +102,23 @@ class RestoreRun extends BaculumAPIServer { } $command = array('restore', - 'file="?' . $rfile . '"', 'client="' . $client . '"' ); + if (is_string($rfile)) { + // Restore using Bvfs + $command[] = 'file="?' . $rfile . '"'; + } elseif ($full === true && is_int($jobid) && $jobid > 0 && is_string($fileset)) { + // Full restore all files + $command[] = 'jobid="' . $jobid . '"'; + $command[] = 'fileset="' . $fileset . '"'; + $command[] = 'select'; + $command[] = 'all'; + $command[] = 'done'; + } if (is_string($replace)) { $command[] = 'replace="' . $replace . '"'; } - if (is_int($priority)) { - $command[] = 'priority="' . $priority . '"'; - } if (is_string($restorejob)) { $command[] = 'restorejob="' . $restorejob . '"'; } diff --git a/gui/baculum/protected/API/openapi_baculum.json b/gui/baculum/protected/API/openapi_baculum.json index ef0ed0b8b..b24102901 100644 --- a/gui/baculum/protected/API/openapi_baculum.json +++ b/gui/baculum/protected/API/openapi_baculum.json @@ -1621,22 +1621,12 @@ { "name": "create[id]", "in": "body", - "description": "Job identifier", - "required": true, + "description": "Job identifier (for full restore)", + "required": false, "schema": { "type": "integer" } }, - { - "name": "create[name]", - "in": "body", - "description": "Job name (can be used instead id)", - "required": true, - "schema": { - "type": "string", - "pattern": "[a-zA-Z0-9:.-_ ]+" - } - }, { "name": "create[clientid]", "in": "body", @@ -1656,32 +1646,50 @@ "pattern": "[a-zA-Z0-9:.-_ ]+" } }, + { + "name": "create[where]", + "in": "body", + "description": "Where to restore files", + "required": true, + "schema": { + "type": "string" + } + }, { "name": "create[rpath]", "in": "body", "description": "Rpath (restore path)", - "required": true, + "required": false, "schema": { "type": "string", "pattern": "b2[0-9]+" } }, { - "name": "create[where]", + "name": "create[full]", "in": "body", - "description": "Where to restore files", - "required": true, + "description": "Full restore all files", + "required": false, + "schema": { + "type": "boolean" + } + }, + { + "name": "create[filesetid]", + "in": "body", + "description": "FileSet identifier (for full restore)", + "required": false, "schema": { "type": "string" } }, { - "name": "create[priority]", + "name": "create[fileset]", "in": "body", - "description": "Job priority", + "description": "FileSet (can be used instead of filesetid) (for full restore)", "required": false, "schema": { - "type": "integer" + "type": "string" } }, { diff --git a/gui/baculum/protected/Web/Lang/en/messages.mo b/gui/baculum/protected/Web/Lang/en/messages.mo index 12a4ad79e..94925bd3c 100644 Binary files a/gui/baculum/protected/Web/Lang/en/messages.mo and b/gui/baculum/protected/Web/Lang/en/messages.mo differ diff --git a/gui/baculum/protected/Web/Lang/en/messages.po b/gui/baculum/protected/Web/Lang/en/messages.po index af7471b1b..e631cedce 100644 --- a/gui/baculum/protected/Web/Lang/en/messages.po +++ b/gui/baculum/protected/Web/Lang/en/messages.po @@ -2923,3 +2923,6 @@ msgstr "Apache, Lighttpd and Nginx on most UNIX platforms" msgid "Nginx on most UNIX platforms" msgstr "Nginx on most UNIX platforms" + +msgid "No file found for selected backup. It can mean file records for this backup are pruned. Restoring selected files is not available but if you continue, there will be performed full restore all backup files." +msgstr "No file found for selected backup. It can mean file records for this backup are pruned. Restoring selected files is not available but if you continue, there will be performed full restore all backup files." diff --git a/gui/baculum/protected/Web/Lang/ja/messages.mo b/gui/baculum/protected/Web/Lang/ja/messages.mo index cb0b4a519..facba96b9 100644 Binary files a/gui/baculum/protected/Web/Lang/ja/messages.mo and b/gui/baculum/protected/Web/Lang/ja/messages.mo differ diff --git a/gui/baculum/protected/Web/Lang/ja/messages.po b/gui/baculum/protected/Web/Lang/ja/messages.po index 844d641d8..00303cf36 100644 --- a/gui/baculum/protected/Web/Lang/ja/messages.po +++ b/gui/baculum/protected/Web/Lang/ja/messages.po @@ -3009,3 +3009,6 @@ msgstr "Apache, Lighttpd and Nginx on most UNIX platforms" msgid "Nginx on most UNIX platforms" msgstr "Nginx on most UNIX platforms" + +msgid "No file found for selected backup. It can mean file records for this backup are pruned. Restoring selected files is not available but if you continue, there will be performed full restore all backup files." +msgstr "No file found for selected backup. It can mean file records for this backup are pruned. Restoring selected files is not available but if you continue, there will be performed full restore all backup files." diff --git a/gui/baculum/protected/Web/Lang/pl/messages.mo b/gui/baculum/protected/Web/Lang/pl/messages.mo index 37e5396ee..29907b454 100644 Binary files a/gui/baculum/protected/Web/Lang/pl/messages.mo and b/gui/baculum/protected/Web/Lang/pl/messages.mo differ diff --git a/gui/baculum/protected/Web/Lang/pl/messages.po b/gui/baculum/protected/Web/Lang/pl/messages.po index 5fd36b2a6..b6b4ddcdb 100644 --- a/gui/baculum/protected/Web/Lang/pl/messages.po +++ b/gui/baculum/protected/Web/Lang/pl/messages.po @@ -2932,3 +2932,5 @@ msgstr "Apache, Lighttpd i Nginx na większości platform UNIX-owych" msgid "Nginx on most UNIX platforms" msgstr "Nginx na większości platform UNIXowych" +msgid "No file found for selected backup. It can mean file records for this backup are pruned. Restoring selected files is not available but if you continue, there will be performed full restore all backup files." +msgstr "Nie znaleziono żadnego pliku dla wybranej kopii zapasowej. Może to oznaczać, że rekordy plików dla tej kopii są wyczyszczone. Przywracanie wybranych plików nie jest dostępne, ale jeżeli kontynuujesz, to zostanie wykonane pełne przywrócenie wszystkich plików kopii zapasowej." diff --git a/gui/baculum/protected/Web/Lang/pt/messages.mo b/gui/baculum/protected/Web/Lang/pt/messages.mo index 2feb57a28..489351f24 100644 Binary files a/gui/baculum/protected/Web/Lang/pt/messages.mo and b/gui/baculum/protected/Web/Lang/pt/messages.mo differ diff --git a/gui/baculum/protected/Web/Lang/pt/messages.po b/gui/baculum/protected/Web/Lang/pt/messages.po index 074a6dc5c..1813f70ea 100644 --- a/gui/baculum/protected/Web/Lang/pt/messages.po +++ b/gui/baculum/protected/Web/Lang/pt/messages.po @@ -2932,3 +2932,5 @@ msgstr "Apache, Lighttpd e Nginx na maioria das plataformas UNIX" msgid "Nginx on most UNIX platforms" msgstr "Nginx na maioria das plataformas UNIX" +msgid "No file found for selected backup. It can mean file records for this backup are pruned. Restoring selected files is not available but if you continue, there will be performed full restore all backup files." +msgstr "No file found for selected backup. It can mean file records for this backup are pruned. Restoring selected files is not available but if you continue, there will be performed full restore all backup files." diff --git a/gui/baculum/protected/Web/Pages/RestoreWizard.page b/gui/baculum/protected/Web/Pages/RestoreWizard.page index cec294c86..d8361eb3c 100644 --- a/gui/baculum/protected/Web/Pages/RestoreWizard.page +++ b/gui/baculum/protected/Web/Pages/RestoreWizard.page @@ -386,6 +386,9 @@ oJobsToRestoreList.init(); + + <%[ No file found for selected backup. It can mean file records for this backup are pruned. Restoring selected files is not available but if you continue, there will be performed full restore all backup files. ]%> +
<%[ Path: ]%>
@@ -686,12 +689,6 @@ oJobsToRestoreList.init();
-
-
-
- -
-
<%[ File relocation option: ]%>
@@ -817,10 +814,6 @@ oJobsToRestoreList.init();
-
-
<%[ Restore job priority: ]%>
-
<%=$this->RestoreJobPriority->Text%>
-
<%[ File relocation option: ]%>
diff --git a/gui/baculum/protected/Web/Pages/RestoreWizard.php b/gui/baculum/protected/Web/Pages/RestoreWizard.php index 1da3eba8f..602d2188c 100644 --- a/gui/baculum/protected/Web/Pages/RestoreWizard.php +++ b/gui/baculum/protected/Web/Pages/RestoreWizard.php @@ -113,7 +113,6 @@ class RestoreWizard extends BaculumWebPage * @return none */ public function setPreDefinedJobIdToRestore() { - $jobid = 0; if ($this->Request->contains('jobid')) { $jobid = intval($this->Request['jobid']); $this->setRestoreByJobId($jobid); @@ -424,6 +423,11 @@ class RestoreWizard extends BaculumWebPage array_unshift($elements, $this->browser_root_dir); } } + if (count($elements) > 0) { + $this->NoFileFound->Display = 'None'; + } elseif (isset($_SESSION['restore_single_jobid'])) { + $this->NoFileFound->Display = 'Dynamic'; + } $this->loadBrowserFiles($elements); } @@ -857,37 +861,48 @@ class RestoreWizard extends BaculumWebPage } $jobid = null; + $ret = new stdClass; + $restore_props = []; + $restore_props['client'] = $this->RestoreClient->SelectedValue; + if ($_SESSION['file_relocation'] == 2) { + if (!empty($this->RestoreStripPrefix->Text)) { + $restore_props['strip_prefix'] = $this->RestoreStripPrefix->Text; + } + if (!empty($this->RestoreAddPrefix->Text)) { + $restore_props['add_prefix'] = $this->RestoreAddPrefix->Text; + } + if (!empty($this->RestoreAddSuffix->Text)) { + $restore_props['add_suffix'] = $this->RestoreAddSuffix->Text; + } + } elseif ($_SESSION['file_relocation'] == 3) { + if (!empty($this->RestoreRegexWhere->Text)) { + $restore_props['regex_where'] = $this->RestoreRegexWhere->Text; + } + } + if (!key_exists('add_prefix', $restore_props)) { + $restore_props['where'] = $this->RestorePath->Text; + } + $restore_props['replace'] = $this->ReplaceFiles->SelectedValue; + $restore_props['restorejob'] = $this->RestoreJob->SelectedValue; if ($is_element) { $this->getModule('api')->create(array('bvfs', 'restore'), $cmd_props); - $restore_props = array(); $restore_props['rpath'] = $path; - $restore_props['client'] = $this->RestoreClient->SelectedValue; - $restore_props['priority'] = intval($this->RestoreJobPriority->Text); - if ($_SESSION['file_relocation'] == 2) { - if (!empty($this->RestoreStripPrefix->Text)) { - $restore_props['strip_prefix'] = $this->RestoreStripPrefix->Text; - } - if (!empty($this->RestoreAddPrefix->Text)) { - $restore_props['add_prefix'] = $this->RestoreAddPrefix->Text; - } - if (!empty($this->RestoreAddSuffix->Text)) { - $restore_props['add_suffix'] = $this->RestoreAddSuffix->Text; - } - } elseif ($_SESSION['file_relocation'] == 3) { - if (!empty($this->RestoreRegexWhere->Text)) { - $restore_props['regex_where'] = $this->RestoreRegexWhere->Text; - } - } - if (!key_exists('add_prefix', $restore_props)) { - $restore_props['where'] = $this->RestorePath->Text; - } - $restore_props['replace'] = $this->ReplaceFiles->SelectedValue; - $restore_props['restorejob'] = $this->RestoreJob->SelectedValue; $ret = $this->getModule('api')->create(array('jobs', 'restore'), $restore_props); $jobid = $this->getModule('misc')->findJobIdStartedJob($ret->output); // Remove temporary BVFS table $this->getModule('api')->set(array('bvfs', 'cleanup'), array('path' => $path)); + } elseif (count($_SESSION['files_browser']) === 0 && isset($_SESSION['restore_single_jobid'])) { + $restore_props['full'] = 1; + $restore_props['id'] = $_SESSION['restore_single_jobid']; + $job = $this->getModule('api')->get(array('jobs', $_SESSION['restore_single_jobid']))->output; + if (is_object($job)) { + $restore_props['fileset'] = $job->fileset; + } + $ret = $this->getModule('api')->create(array('jobs', 'restore'), $restore_props); + $jobid = $this->getModule('misc')->findJobIdStartedJob($ret->output); + } else { + $ret->output = ['No file to restore found']; } $url_params = array(); if (is_numeric($jobid)) {