3 * Bacula® - The Network Backup Solution
4 * Baculum - Bacula web interface
6 * Copyright (C) 2013-2015 Marcin Haba
8 * The main author of Baculum is Marcin Haba.
9 * The main author of Bacula is Kern Sibbald, with contributions from many
10 * others, a complete list can be found in the file AUTHORS.
12 * You may use this file and others of this release according to the
13 * license defined in the LICENSE file, which includes the Affero General
14 * Public License, v3.0 ("AGPLv3") and some additional permissions and
15 * terms pursuant to its AGPLv3 Section 7.
17 * Bacula® is a registered trademark of Kern Sibbald.
20 class RestoreRun extends BaculumAPI {
22 public function get() {}
24 public function create($params) {
25 $rfile = property_exists($params, 'rpath') ? $params->rpath : null;
26 $clientid = property_exists($params, 'clientid') ? intval($params->clientid) : null;
27 $fileset = property_exists($params, 'fileset') ? $params->fileset : null;
28 $priority = property_exists($params, 'priority') ? intval($params->priority) : null;
29 $where = property_exists($params, 'where') ? $params->where : null;
30 $replace = property_exists($params, 'replace') ? $params->replace : null;
32 $client = $this->getModule('client')->getClientById($clientid);
34 if(!is_null($fileset)) {
35 if(!is_null($client)) {
36 if(preg_match('/^b2[\d]+$/', $rfile) === 1) {
37 if(!is_null($where)) {
38 if(!is_null($replace)) {
39 $restore = $this->getModule('bconsole')->bconsoleCommand($this->director, array('restore', 'file="?' . $rfile . '"', 'client="' . $client->name . '"', 'where="' . $where . '"', 'replace="' . $replace . '"', 'fileset="' . $fileset . '"', 'priority="' . $priority . '"', 'yes'), $this->user);
40 $this->output = $restore->output;
41 $this->error = (integer)$restore->exitcode;
43 $this->output = JobError::MSG_ERROR_INVALID_REPLACE_OPTION;
44 $this->error = JobError::ERROR_INVALID_REPLACE_OPTION;
47 $this->output = JobError::MSG_ERROR_INVALID_WHERE_OPTION;
48 $this->error = JobError::ERROR_INVALID_WHERE_OPTION;
51 $this->output = JobError::MSG_ERROR_INVALID_RPATH;
52 $this->error = JobError::ERROR_INVALID_RPATH;
55 $this->output = JobError::MSG_ERROR_CLIENTID_DOES_NOT_EXISTS;
56 $this->error = JobError::ERROR_CLIENTID_DOES_NOT_EXISTS;
59 $this->output = JobError::MSG_ERROR_FILESETID_DOES_NOT_EXISTS;
60 $this->error = JobError::ERROR_FILESETID_DOES_NOT_EXISTS;