]> git.ipfire.org Git - thirdparty/bacula.git/commitdiff
baculum: Request #2546 support for full restore when file records for backup job...
authorMarcin Haba <marcin.haba@bacula.pl>
Fri, 29 May 2020 05:57:40 +0000 (07:57 +0200)
committerMarcin Haba <marcin.haba@bacula.pl>
Fri, 29 May 2020 05:57:40 +0000 (07:57 +0200)
15 files changed:
gui/baculum/protected/API/Lang/en/messages.mo
gui/baculum/protected/API/Lang/pl/messages.mo
gui/baculum/protected/API/Lang/pt/messages.mo
gui/baculum/protected/API/Pages/API/RestoreRun.php
gui/baculum/protected/API/openapi_baculum.json
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/RestoreWizard.page
gui/baculum/protected/Web/Pages/RestoreWizard.php

index 8b96c598173201720d753f73a8931ac9905e4475..87d3647b8e30d53326a4eec1561d7901c5dfc3a6 100644 (file)
Binary files a/gui/baculum/protected/API/Lang/en/messages.mo and b/gui/baculum/protected/API/Lang/en/messages.mo differ
index 7f9e93b0013335949156214d4cd280534503aad9..c0f969d3518491bb0079cf99c6f13cc3e2a7d91e 100644 (file)
Binary files a/gui/baculum/protected/API/Lang/pl/messages.mo and b/gui/baculum/protected/API/Lang/pl/messages.mo differ
index 4a69ac99fca3ec8b0820776fd24d42d46a8cf57b..896a7b04b1959cd2b04eb612e0be2ed2036e35e6 100644 (file)
Binary files a/gui/baculum/protected/API/Lang/pt/messages.mo and b/gui/baculum/protected/API/Lang/pt/messages.mo differ
index dbf57440d513c1e4b112c98b61863601a6d097bf..446c5975ec12f3ee856d031175c8bf75393d4929 100644 (file)
@@ -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 . '"';
                }
index ef0ed0b8b10e75ddb8959ef5fa6e1b5adcbea54a..b241029012c0d12f2939c41d9eff88d987624bea 100644 (file)
                                        {
                                                "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",
                                                        "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"
                                                }
                                        },
                                        {
index 12a4ad79e34017d4d74068fb082e253f8ea017cb..94925bd3c744d17a0234f2e31f7ac6763cb7f5f5 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 af7471b1bd9798ee8255f0406bb10452f6a88a98..e631cedce9e4d229b76f679bbd56232c31a386fd 100644 (file)
@@ -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."
index cb0b4a519b3ce7ec8ce8afaf8912d5832ddd3485..facba96b9cf1476347bb87143effde95d43d73a5 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 844d641d8a736d6e4d85e3fc7644550dd6baa3e0..00303cf36c02d6de3e3bb4e316a224e977f80c81 100644 (file)
@@ -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."
index 37e5396ee024280416086382545648a66ddf4103..29907b4545e4d7c591088f73dba87baf20f4f0be 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 5fd36b2a649f2ce4ccc31d2101767522e337fbba..b6b4ddcdb473bd12008ec505d9518a3e82b63e57 100644 (file)
@@ -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."
index 2feb57a28924fd68d549b00a5d70c46b3ed40966..489351f2427a39b1bb3297b6fa93395d5f35f4e3 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 074a6dc5c90cf66933429a71e2f5334235c544c8..1813f70ea06533b4da8819a2f091e3cac8d19dc1 100644 (file)
@@ -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."
index cec294c86924fe7038947a7dfb9091cdb4237b89..d8361eb3c23e14b0670536ba5d600aef9135418a 100644 (file)
@@ -386,6 +386,9 @@ oJobsToRestoreList.init();
                        </div>
                </com:TWizardStep>
                <com:TWizardStep ID="Step3" Title="<%[ Step 3 - select files to restore ]%>" StepType="Auto">
+                       <com:TPanel ID="NoFileFound" Style="height: 38px" Display="None">
+                                       <%[ 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. ]%>
+                       </com:TPanel>
                        <div class="w3-row">
                                <div class="w3-col" style="width: 15%;"><%[ Path: ]%></div>
                                <div class="w3-col" style="width: 85%;">
@@ -686,12 +689,6 @@ oJobsToRestoreList.init();
                                        </com:TDropDownList>
                                </div>
                        </div>
-                       <div class="w3-section w3-row">
-                               <div class="w3-col w3-third"><com:TLabel ForControl="RestoreJobPriority" Text="<%[ Restore job priority: ]%>" /></div>
-                               <div class="w3-col w3-third">
-                                       <com:TTextBox ID="RestoreJobPriority" CssClass="w3-input w3-border" CausesValidation="false" MaxLength="5" Text="10" />
-                               </div>
-                       </div>
                        <div class="w3-section w3-row w3-margin-bottom">
                                <div class="w3-col w3-third"><%[ File relocation option:  ]%></div>
                                <div class="w3-col w3-third">
@@ -817,10 +814,6 @@ oJobsToRestoreList.init();
                                                <com:TLabel Visible="<%=$this->ReplaceFiles->SelectedValue == 'always'%>" Text="<%[ always replace files ]%>"/>
                                        </div>
                                </div>
-                               <div class="w3-section w3-row">
-                                       <div class="w3-col w3-third"><%[ Restore job priority: ]%></div>
-                                       <div class="w3-col w3-third bold"><%=$this->RestoreJobPriority->Text%></div>
-                               </div>
                                <div class="w3-section w3-row">
                                        <div class="w3-col w3-third"><%[ File relocation option: ]%></div>
                                        <div class="w3-col w3-third bold">
index 1da3eba8f26a0f6265ffec80adc566b2caca512a..602d2188c8e995d3588800d023b468216111f9fa 100644 (file)
@@ -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)) {