* Bacula(R) - The Network Backup Solution
* Baculum - Bacula web interface
*
- * Copyright (C) 2013-2016 Kern Sibbald
+ * Copyright (C) 2013-2017 Kern Sibbald
*
* The main author of Baculum is Marcin Haba.
* The original author of Bacula is Kern Sibbald, with contributions
class JobTasks extends BaculumAPIServer {
public function get() {
$limit = intval($this->Request['limit']);
+ $jobs_cmd = array('.jobs');
+ if ($this->Request->contains('type') && array_key_exists($this->Request['type'], $this->getModule('misc')->job_types)) {
+ array_push($jobs_cmd, 'type="' . $this->Request['type']. '"');
+ }
+
$directors = $this->getModule('bconsole')->getDirectors();
if($directors->exitcode === 0) {
$jobs = array();
$error = false;
$error_obj = null;
for($i = 0; $i < count($directors->output); $i++) {
- $jobsList = $this->getModule('bconsole')->bconsoleCommand($directors->output[$i], array('.jobs'), $this->user);
+ $jobsList = $this->getModule('bconsole')->bconsoleCommand($directors->output[$i], $jobs_cmd, $this->user);
if ($jobsList->exitcode != 0) {
$error_obj = $jobsList;
$error = true;
* Bacula(R) - The Network Backup Solution
* Baculum - Bacula web interface
*
- * Copyright (C) 2013-2016 Kern Sibbald
+ * Copyright (C) 2013-2017 Kern Sibbald
*
* The main author of Baculum is Marcin Haba.
* The original author of Bacula is Kern Sibbald, with contributions
$priority = property_exists($params, 'priority') ? intval($params->priority) : 10; // default priority is set to 10
$where = property_exists($params, 'where') ? $params->where : null;
$replace = property_exists($params, 'replace') ? $params->replace : null;
+ $restorejob = null;
+ if (property_exists($params, 'restorejob') && $this->getModule('misc')->isValidName($params->restorejob)) {
+ $restorejob = $params->restorejob;
+ }
$misc = $this->getModule('misc');
if(!is_null($fileset)) {
'where="' . $where . '"',
'replace="' . $replace . '"',
'fileset="' . $fileset . '"',
- 'priority="' . $priority . '"',
- 'yes'
+ 'priority="' . $priority . '"'
);
+ if (!is_null($restorejob)) {
+ $command[] = 'restorejob="' . $restorejob . '"';
+ }
+ $command[] = 'yes';
$restore = $this->getModule('bconsole')->bconsoleCommand($this->director, $command, $this->user);
$this->removeTmpRestoreTable($rfile);
$this->output = $restore->output;
<!-- jobs endpoints-->
<url ServiceParameter="API.Jobs" pattern="api/jobs/" />
<url ServiceParameter="API.JobTasks" pattern="api/jobs/tasks/" />
+ <url ServiceParameter="API.JobTasks" pattern="api/jobs/tasks/type/{type}" parameters.type="[a-zA-Z]" />
+ <url ServiceParameter="API.JobTasks" pattern="api/jobs/tasks/type/{type}/limit/{limit}/" parameters.type="[a-zA-Z]" parameters.limit="\d+" />
<url ServiceParameter="API.JobTasks" pattern="api/jobs/tasks/limit/{limit}/" parameters.limit="\d+" />
<url ServiceParameter="API.Job" pattern="api/jobs/{id}/" parameters.id="\d+" />
<url ServiceParameter="API.Jobs" pattern="api/jobs/limit/{limit}/" parameters.limit="\d+" />
const RPATH_PATTERN = '/^b2\d+$/';
- private $jobTypes = array(
+ public $job_types = array(
'B' => 'Backup',
'M' => 'Migrated',
'V' => 'Verify',
return $name;
}
- public function getJobType($jobTypeLetter = null) {
- $type;
- if(is_null($jobTypeLetter)) {
- $type = $this->jobTypes;
- } else {
- $type = array_key_exists($jobTypeLetter, $this->jobTypes) ? $this->jobTypes[$jobTypeLetter] : null;
- }
- return $type;
-
- }
-
public function getJobStatesByType($type) {
$statesByType = array();
$states = array();
msgid "OAuth2 Scope:"
msgstr "OAuth2 Scope:"
+
+msgid "Restore job:"
+msgstr "Restore job:"
msgid "No jobs for the client."
msgstr "No jobs for the client."
+
+msgid "Restore job:"
+msgstr "Restore job:"
msgid "OAuth2 Scope:"
msgstr "Zakresy OAuth2:"
+msgid "Restore job:"
+msgstr "Zadanie przywracania:"
msgid "OAuth2 Scope:"
msgstr "OAuth2 Scope:"
+msgid "Restore job:"
+msgstr "Restore job:"
</div>
</com:TWizardStep>
<com:TWizardStep ID="Step5" Title="<%[ Step 5 - options for restore ]%>" StepType="Auto">
+ <div class="line">
+ <div class="text"><com:TLabel ForControl="RestoreJob" Text="<%[ Restore job: ]%>" /></div>
+ <div class="field">
+ <com:TActiveDropDownList ID="RestoreJob" CssClass="textbox" Width="350px" CausesValidation="false" />
+ </div>
+ </div>
<div class="line">
<div class="text"><com:TLabel ForControl="ReplaceFiles" Text="<%[ Replace files: ]%>" /></div>
<div class="field">
</fieldset>
<fieldset>
<legend><%[ Restore job options ]%></legend>
+ <div class="line">
+ <div class="text"><%[ Restore job: ]%></div>
+ <div class="field bold"><%=$this->RestoreJob->Text%></div>
+ </div>
<div class="line">
<div class="text"><%[ Replace files: ]%></div>
<div class="field bold">
* Bacula(R) - The Network Backup Solution
* Baculum - Bacula web interface
*
- * Copyright (C) 2013-2016 Kern Sibbald
+ * Copyright (C) 2013-2017 Kern Sibbald
*
* The main author of Baculum is Marcin Haba.
* The original author of Bacula is Kern Sibbald, with contributions
$this->setFileVersions(array());
$this->setFilesToRestore(array());
$this->markFileToRestore(null, null);
+ $this->setRestoreJobs();
$_SESSION['restore_path'] = array();
}
}
public function wizardCompleted() {
$jobids = $this->getElementaryBackup();
$path = self::BVFS_PATH_PREFIX . getmypid();
- $restoreElements = $this->getRestoreElements();
- $cmdProps = array('jobids' => $jobids, 'path' => $path);
- if(count($restoreElements['fileid']) > 0) {
- $cmdProps['fileid'] = implode(',', $restoreElements['fileid']);
+ $restore_elements = $this->getRestoreElements();
+ $cmd_props = array('jobids' => $jobids, 'path' => $path);
+ if(count($restore_elements['fileid']) > 0) {
+ $cmd_props['fileid'] = implode(',', $restore_elements['fileid']);
}
- if(count($restoreElements['dirid']) > 0) {
- $cmdProps['dirid'] = implode(',', $restoreElements['dirid']);
+ if(count($restore_elements['dirid']) > 0) {
+ $cmd_props['dirid'] = implode(',', $restore_elements['dirid']);
}
- $this->getModule('api')->create(array('bvfs', 'restore'), $cmdProps);
- $restoreProps = array();
- $restoreProps['rpath'] = $path;
- $restoreProps['clientid'] = intval($this->RestoreClient->SelectedValue);
- $restoreProps['fileset'] = $this->GroupBackupFileSet->SelectedValue;
- $restoreProps['priority'] = intval($this->RestoreJobPriority->Text);
- $restoreProps['where'] = $this->RestorePath->Text;
- $restoreProps['replace'] = $this->ReplaceFiles->SelectedValue;
+ $this->getModule('api')->create(array('bvfs', 'restore'), $cmd_props);
+ $restore_props = array();
+ $restore_props['rpath'] = $path;
+ $restore_props['clientid'] = intval($this->RestoreClient->SelectedValue);
+ $restore_props['fileset'] = $this->GroupBackupFileSet->SelectedValue;
+ $restore_props['priority'] = intval($this->RestoreJobPriority->Text);
+ $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'), $restoreProps);
+ $ret = $this->getModule('api')->create(array('jobs', 'restore'), $restore_props);
$jobid = $this->getModule('misc')->findJobIdStartedJob($ret->output);
- $urlParams = array('open' => 'Job');
+ $url_params = array('open' => 'Job');
if (is_numeric($jobid)) {
- $urlParams['id'] = $jobid;
+ $url_params['id'] = $jobid;
}
- $this->goToDefaultPage($urlParams);
+ $this->goToDefaultPage($url_params);
+ }
+
+ private function setRestoreJobs() {
+ $restore_job_tasks = $this->Application->getModule('api')->get(array('jobs', 'tasks', 'type', 'R'))->output;
+ $jobs = array();
+ foreach ($restore_job_tasks as $director => $restore_jobs) {
+ $jobs = array_merge($jobs, $restore_jobs);
+ }
+ $this->RestoreJob->DataSource = array_combine($jobs, $jobs);
+ $this->RestoreJob->dataBind();
}
}
?>
* Bacula(R) - The Network Backup Solution
* Baculum - Bacula web interface
*
- * Copyright (C) 2013-2016 Kern Sibbald
+ * Copyright (C) 2013-2017 Kern Sibbald
*
* The main author of Baculum is Marcin Haba.
* The original author of Bacula is Kern Sibbald, with contributions
$misc = $this->Application->getModule('misc');
$this->jobLevels = $misc->getJobLevels();
$this->jobStates = $misc->getJobState();
- $this->jobTypes = $misc->getJobType();
+ $this->jobTypes = $misc->job_types;
$this->runningJobStates = $misc->getRunningJobStates();
}