From: Marcin Haba Date: Sun, 1 Dec 2019 13:26:16 +0000 (+0100) Subject: baculum: Add support to restore from copy jobs X-Git-Tag: Release-9.6.0~61 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=94ecfc75483ce311561254728daf41479cdf2533;p=thirdparty%2Fbacula.git baculum: Add support to restore from copy jobs --- diff --git a/gui/baculum/protected/Web/Lang/en/messages.mo b/gui/baculum/protected/Web/Lang/en/messages.mo index f5f25b530..c7a7775c9 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 86bc3682d..65a3578b6 100644 --- a/gui/baculum/protected/Web/Lang/en/messages.po +++ b/gui/baculum/protected/Web/Lang/en/messages.po @@ -2512,3 +2512,6 @@ msgstr "Volume recycling" msgid "Tip: checking 'All' message type causes, that rest checked message types are saved with negation ex. Catalog = All, !Debug, !Saved, !Skipped" msgstr "Tip: checking 'All' message type causes, that rest checked message types are saved with negation ex. Catalog = All, !Debug, !Saved, !Skipped" + +msgid "Enable restore from copy jobs feature:" +msgstr "Enable restore from copy jobs feature:" diff --git a/gui/baculum/protected/Web/Lang/ja/messages.mo b/gui/baculum/protected/Web/Lang/ja/messages.mo index 6a13e2b19..0b8d16ec6 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 483e15440..5f3f74b06 100644 --- a/gui/baculum/protected/Web/Lang/ja/messages.po +++ b/gui/baculum/protected/Web/Lang/ja/messages.po @@ -2598,3 +2598,6 @@ msgstr "Volume recycling" msgid "Tip: checking 'All' message type causes, that rest checked message types are saved with negation ex. Catalog = All, !Debug, !Saved, !Skipped" msgstr "Tip: checking 'All' message type causes, that rest checked message types are saved with negation ex. Catalog = All, !Debug, !Saved, !Skipped" + +msgid "Enable restore from copy jobs feature:" +msgstr "Enable restore from copy jobs feature:" diff --git a/gui/baculum/protected/Web/Lang/pl/messages.mo b/gui/baculum/protected/Web/Lang/pl/messages.mo index a58b60314..f246ab3ed 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 aa9db1c73..238f90ebf 100644 --- a/gui/baculum/protected/Web/Lang/pl/messages.po +++ b/gui/baculum/protected/Web/Lang/pl/messages.po @@ -2519,3 +2519,6 @@ msgstr "Recykling wolumenów" msgid "Tip: checking 'All' message type causes, that rest checked message types are saved with negation ex. Catalog = All, !Debug, !Saved, !Skipped" msgstr "Porada: zaznaczenie typu wiadomości 'All' powoduje, że reszta zaznaczonych typów wiadomości jest zapisana z negacją np. Catalog = All, !Debug, !Saved, !Skipped" + +msgid "Enable restore from copy jobs feature:" +msgstr "Włącz funkcję przywracania danych z kopii zadań:" diff --git a/gui/baculum/protected/Web/Lang/pt/messages.mo b/gui/baculum/protected/Web/Lang/pt/messages.mo index f3533073d..5fed9cc46 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 8e1aa112a..971c2c660 100644 --- a/gui/baculum/protected/Web/Lang/pt/messages.po +++ b/gui/baculum/protected/Web/Lang/pt/messages.po @@ -2527,3 +2527,6 @@ msgstr "Volume recycling" msgid "Tip: checking 'All' message type causes, that rest checked message types are saved with negation ex. Catalog = All, !Debug, !Saved, !Skipped" msgstr "Tip: checking 'All' message type causes, that rest checked message types are saved with negation ex. Catalog = All, !Debug, !Saved, !Skipped" + +msgid "Enable restore from copy jobs feature:" +msgstr "Enable restore from copy jobs feature:" diff --git a/gui/baculum/protected/Web/Pages/JobHistoryView.php b/gui/baculum/protected/Web/Pages/JobHistoryView.php index bf26a1e82..9c557f20f 100644 --- a/gui/baculum/protected/Web/Pages/JobHistoryView.php +++ b/gui/baculum/protected/Web/Pages/JobHistoryView.php @@ -50,6 +50,7 @@ class JobHistoryView extends BaculumWebPage { private $no_graph_mode_verify_levels = array('O'); private $list_files_types = array('B', 'C', 'V'); private $list_files_mode_verify_levels = array('V'); + private $show_restore_types = array('B', 'C'); public function onPreInit($param) { parent::onPreInit($param); @@ -294,7 +295,7 @@ class JobHistoryView extends BaculumWebPage { $this->RunningIcon->Display = 'None'; $this->CancelBtn->Display = 'None'; $this->DeleteBtn->Display = 'Dynamic'; - $this->RestoreBtn->Display = $this->getJobType() == 'B' ? 'Dynamic' : 'None'; + $this->RestoreBtn->Display = $this->isShowRestoreBtn() ? 'Dynamic' : 'None'; } if ($this->getJobLogOrder() === self::SORT_DESC) { $joblog = array_reverse($joblog); @@ -304,6 +305,11 @@ class JobHistoryView extends BaculumWebPage { $this->JobLog->Text = implode(PHP_EOL, $joblog); } + private function isShowRestoreBtn() { + $type = $this->getJobType(); + return in_array($type, $this->show_restore_types); + } + public function loadRunJobModal($sender, $param) { $this->RunJobModal->loadData(); } diff --git a/gui/baculum/protected/Web/Pages/RestoreWizard.page b/gui/baculum/protected/Web/Pages/RestoreWizard.page index 80e3122da..6ad943e51 100644 --- a/gui/baculum/protected/Web/Pages/RestoreWizard.page +++ b/gui/baculum/protected/Web/Pages/RestoreWizard.page @@ -130,6 +130,12 @@ +
+
+
+ +
+

@@ -327,7 +333,7 @@ var oJobsToRestoreList = { }], order: [1, 'desc'], initComplete: function () { - this.api().columns([2, 4, 5]).every(function () { + this.api().columns([2, 3, 4, 5]).every(function () { var column = this; var select = $('') .appendTo($(column.footer()).empty()) diff --git a/gui/baculum/protected/Web/Pages/RestoreWizard.php b/gui/baculum/protected/Web/Pages/RestoreWizard.php index f4275d679..f868d3141 100644 --- a/gui/baculum/protected/Web/Pages/RestoreWizard.php +++ b/gui/baculum/protected/Web/Pages/RestoreWizard.php @@ -271,7 +271,7 @@ class RestoreWizard extends BaculumWebPage $clientid = $this->getBackupClientId(); $jobs_for_client = $this->getModule('api')->get(array('clients', $clientid, 'jobs'))->output; $jobs = $this->getModule('misc')->objectToArray($jobs_for_client); - $this->jobs_to_restore = array_filter($jobs, array($this, 'isBackupJobToRestore')); + $this->jobs_to_restore = array_filter($jobs, array($this, 'isJobToRestore')); } /** @@ -280,8 +280,16 @@ class RestoreWizard extends BaculumWebPage * @param array $job job properties * @return true if job should be listed to restore, otherwise false */ - private function isBackupJobToRestore($job) { - return ($job['type'] === 'B' && in_array($job['level'], $this->joblevel) && in_array($job['jobstatus'], $this->jobstatus)); + private function isJobToRestore($job) { + $jobtype = array('B'); + if ($this->EnableCopyJobRestore->Checked) { + $jobtype[] = 'C'; + } + return ( + in_array($job['type'], $jobtype) && + in_array($job['level'], $this->joblevel) && + in_array($job['jobstatus'], $this->jobstatus) + ); } public function loadBackupSelection($sender, $param) { @@ -342,7 +350,7 @@ class RestoreWizard extends BaculumWebPage $job_group_list = array(); for ($i = 0; $i < count($jobs); $i++) { $job = $this->getModule('misc')->objectToArray($jobs[$i]); - if ($this->isBackupJobToRestore($jobs[$i]) && $jobs[$i]['clientid'] === $clientid) { + if ($this->isJobToRestore($jobs[$i]) && $jobs[$i]['clientid'] === $clientid) { $job_group_list[$jobs[$i]['name']] = $jobs[$i]['name']; } } @@ -438,8 +446,15 @@ class RestoreWizard extends BaculumWebPage private function getElementaryBackup() { $jobids = ''; if ($this->OnlySelectedBackupSelection->Checked && isset($_SESSION['restore_single_jobid'])) { + $params = [ + 'jobid' => $_SESSION['restore_single_jobid'] + ]; + if ($this->EnableCopyJobRestore->Checked) { + $params['inc_copy_job'] = 1; + } + $query = '?' . http_build_query($params); $jobs = $this->getModule('api')->get( - array('bvfs', 'getjobids', '?jobid=' . rawurlencode($_SESSION['restore_single_jobid'])) + array('bvfs', 'getjobids', $query) ); $ids = is_object($jobs) ? $jobs->output : array(); foreach ($ids as $jobid) { @@ -452,15 +467,20 @@ class RestoreWizard extends BaculumWebPage $jobids = $_SESSION['restore_single_jobid']; } } else { - $query = '?client=' . rawurlencode($this->BackupClientName->SelectedValue); - $query .= '&filesetid=' . rawurlencode($this->GroupBackupFileSet->SelectedValue); - $params = array( + $params = [ + 'client' => $this->BackupClientName->SelectedValue, + 'filesetid' => $this->GroupBackupFileSet->SelectedValue + ]; + if ($this->EnableCopyJobRestore->Checked) { + $params['inc_copy_job'] = 1; + } + $query = '?' . http_build_query($params); + $jobs_recent = $this->getModule('api')->get(array( 'jobs', 'recent', $this->GroupBackupToRestore->SelectedValue, $query - ); - $jobs_recent = $this->getModule('api')->get($params); + )); if (count($jobs_recent->output) > 0) { $ids = $jobs_recent->output; $jobids = implode(',', $ids); @@ -584,13 +604,16 @@ class RestoreWizard extends BaculumWebPage return; } $clientname = $this->BackupClientName->SelectedValue; - $query = sprintf( - '?client=%s&jobid=%s&pathid=%s&filenameid=%s', - rawurlencode($clientname), - rawurlencode($jobid), - rawurlencode($pathid), - rawurlencode($filenameid) - ); + $params = [ + 'client' => $clientname, + 'jobid' => $jobid, + 'pathid' => $pathid, + 'filenameid' => $filenameid + ]; + if ($this->EnableCopyJobRestore->Checked) { + $params['copies'] = 1; + } + $query = '?' . http_build_query($params); $versions = $this->getModule('api')->get(array('bvfs', 'versions', $query))->output; $file_versions = $this->getModule('misc')->parseFileVersions($filename, $versions); $file_versions = array_map(array('RestoreWizard', 'addUniqid'), $file_versions);