]> git.ipfire.org Git - thirdparty/bacula.git/commitdiff
baculum: Add support to restore from copy jobs
authorMarcin Haba <marcin.haba@bacula.pl>
Sun, 1 Dec 2019 13:26:16 +0000 (14:26 +0100)
committerMarcin Haba <marcin.haba@bacula.pl>
Sat, 14 Dec 2019 15:02:17 +0000 (16:02 +0100)
gui/baculum/protected/Web/Lang/en/messages.mo
gui/baculum/protected/Web/Lang/en/messages.po
gui/baculum/protected/Web/Lang/ja/messages.mo
gui/baculum/protected/Web/Lang/ja/messages.po
gui/baculum/protected/Web/Lang/pl/messages.mo
gui/baculum/protected/Web/Lang/pl/messages.po
gui/baculum/protected/Web/Lang/pt/messages.mo
gui/baculum/protected/Web/Lang/pt/messages.po
gui/baculum/protected/Web/Pages/JobHistoryView.php
gui/baculum/protected/Web/Pages/RestoreWizard.page
gui/baculum/protected/Web/Pages/RestoreWizard.php

index f5f25b5305610408c4e10481abe0565e58b7467d..c7a7775c9d72cee97163fd94e82f9e35ceb62c64 100644 (file)
Binary files a/gui/baculum/protected/Web/Lang/en/messages.mo and b/gui/baculum/protected/Web/Lang/en/messages.mo differ
index 86bc3682db51a39345ab52d41207d125290a6eb1..65a3578b698f64cef80f54f2d4be9320ff90fdd4 100644 (file)
@@ -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:"
index 6a13e2b1943ee9f09260f396985c55af1fc4cf03..0b8d16ec68df15e54a413bbb87f88cd7918db429 100644 (file)
Binary files a/gui/baculum/protected/Web/Lang/ja/messages.mo and b/gui/baculum/protected/Web/Lang/ja/messages.mo differ
index 483e1544012c6bc310c1bfe654403ecec863968b..5f3f74b06d124c39ccf0c8d79fd248e09b92314c 100644 (file)
@@ -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:"
index a58b6031422cceef1801c98abb6ebb8d2dd27e36..f246ab3ed313b68f079f47c029531c939f431d31 100644 (file)
Binary files a/gui/baculum/protected/Web/Lang/pl/messages.mo and b/gui/baculum/protected/Web/Lang/pl/messages.mo differ
index aa9db1c737e1079f155d6e96906653e3ea17c982..238f90ebf39f9939f193e9d0263c3a729b41663e 100644 (file)
@@ -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ń:"
index f3533073d85b39c9638f941268451998a623621b..5fed9cc460fcc8d3017698fa44ded6b3286bd1ea 100644 (file)
Binary files a/gui/baculum/protected/Web/Lang/pt/messages.mo and b/gui/baculum/protected/Web/Lang/pt/messages.mo differ
index 8e1aa112a56c72e65c592852264de6cf2c54525c..971c2c66050fa85212a86f04455872760f5bf58e 100644 (file)
@@ -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:"
index bf26a1e8263470feb6f47766149826f00565c01b..9c557f20f9d89aec1f9dc2e279179e8d99917c6f 100644 (file)
@@ -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();
        }
index 80e3122da6a2e52b5d91c417eb7a570b323fff73..6ad943e5157058d18d2c2e84e3c04ece0ba4cfc5 100644 (file)
                                        <com:TDropDownList ID="BackupClientName" CssClass="w3-select w3-border" CausesValidation="false" />
                                </div>
                        </div>
+                       <div class="w3-container w3-section">
+                               <div class="w3-third"><com:TLabel ForControl="EnableCopyJobRestore" Text="<%[ Enable restore from copy jobs feature: ]%>" /></div>
+                               <div class="w3-third">
+                                       <com:TCheckBox ID="EnableCopyJobRestore" CssClass="w3-check" CausesValidation="false" Checked="true" />
+                               </div>
+                       </div>
                </com:TWizardStep>
                <com:TWizardStep ID="Step2" Title="<%[ Step 2 - select backup to restore ]%>" StepType="Auto">
                        <p>
@@ -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 = $('<select><option value=""></option></select>')
                                        .appendTo($(column.footer()).empty())
index f4275d67945f77163af195b161e6e34ece156968..f868d314190d8faff3c6298096c702bb1aa9ee70 100644 (file)
@@ -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);