Skip to content
This repository has been archived by the owner on Mar 19, 2021. It is now read-only.

Commit

Permalink
Restore a specific job (jobid)
Browse files Browse the repository at this point in the history
  • Loading branch information
fbergkemper committed May 29, 2015
1 parent 3415535 commit f92679e
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 7 deletions.
8 changes: 5 additions & 3 deletions module/Job/view/job/job/index.phtml
Expand Up @@ -5,7 +5,7 @@
* bareos-webui - Bareos Web-Frontend
*
* @link https://github.com/bareos/bareos-webui for the canonical source repository
* @copyright Copyright (c) 2013-2014 Bareos GmbH & Co. KG (http://www.bareos.org/)
* @copyright Copyright (c) 2013-2015 Bareos GmbH & Co. KG (http://www.bareos.org/)
* @license GNU Affero General Public License (http://www.gnu.org/licenses/)
* @author Frank Bergkemper
*
Expand Down Expand Up @@ -93,7 +93,7 @@ Jobs per page:
<th><a href="<?php echo $this->url('job', array('order_by' => 'duration', 'order' => $url_order, 'limit' => $this->limit)); ?>"><?php echo $this->translate("Duration"); ?></a></th>
<th><a href="<?php echo $this->url('job', array('order_by' => 'JobStatus', 'order' => $url_order, 'limit' => $this->limit)); ?>"><?php echo $this->translate("Status"); ?></a></th>
<th><?php echo $this->translate("Action"); ?></th>

</tr>

<?php foreach ($this->paginator as $job) : ?>
Expand Down Expand Up @@ -122,8 +122,10 @@ Jobs per page:
<li class="divider"></li>
<?php if($job->jobstatus == "T") : ?>
<li><a href="<?php echo $this->url('job', array('action' => 'rerun', 'id' => $job->jobid)); ?>" title="<?php echo $this->translate("Rerun"); ?>"><span class="glyphicon glyphicon-repeat"></span> Re-run job</a></li>
<li><a href="<?php echo $this->url('restore', array('action' => 'index'), array('query' => array('type' => 2, 'job' => $job->jobid, 'client' => $job->clientname, 'restoreclient' => $job->clientname))); ?>"><span class="glyphicon glyphicon-import"></span> Restore job</a></li>
<?php elseif($job->jobstatus == "E" || $job->jobstatus == "e" || $job->jobstatus == "f" || $job->jobstatus == "A") : ?>
<li><a href="<?php echo $this->url('job', array('action' => 'rerun', 'id' => $job->jobid)); ?>" title="<?php echo $this->translate("Rerun"); ?>"><span class="glyphicon glyphicon-repeat"></span> Re-run job</a></li>
<li><a href="<?php echo $this->url('restore', array('action' => 'index'), array('query' => array('type' => 2, 'job' => $job->jobid, 'client' => $job->clientname, 'restoreclient' => $job->clientname))); ?>"><span class="glyphicon glyphicon-import"></span> Restore job</a></li>
<?php else : ?>
<li><a href="<?php echo $this->url('job', array('action' => 'cancel', 'id' => $job->jobid)); ?>" title="<?php echo $this->translate("Cancel"); ?>"><span class="glyphicon glyphicon-trash"></span> Cancel job</a></li>
<?php endif; ?>
Expand All @@ -143,7 +145,7 @@ Jobs per page:
</div>
<?php endif; ?>
</td>

</tr>

<?php endforeach; ?>
Expand Down
1 change: 1 addition & 0 deletions module/Job/view/job/job/successful.phtml
Expand Up @@ -142,6 +142,7 @@ Jobs per page:
<?php if($job->type != "R") : ?>
<li class="divider"></li>
<li><a href="<?php echo $this->url('job', array('action' => 'rerun', 'id' => $job->jobid)); ?>" title="<?php echo $this->translate("Rerun"); ?>"><span class="glyphicon glyphicon-repeat"></span> Re-run job</a></li>
<li><a href="<?php echo $this->url('restore', array('action' => 'index'), array('query' => array('type' => 2, 'job' => $job->jobid, 'client' => $job->clientname, 'restoreclient' => $job->clientname))); ?>"><span class="glyphicon glyphicon-import"></span> Restore job</a></li>
<?php endif; ?>
</ul>
</div>
Expand Down
1 change: 1 addition & 0 deletions module/Job/view/job/job/unsuccessful.phtml
Expand Up @@ -137,6 +137,7 @@ Jobs per page:
<?php if($job->type != "R") : ?>
<li class="divider"></li>
<li><a href="<?php echo $this->url('job', array('action' => 'rerun', 'id' => $job->jobid)); ?>" title="<?php echo $this->translate("Rerun"); ?>"><span class="glyphicon glyphicon-repeat"></span> Re-run job</a></li>
<li><a href="<?php echo $this->url('restore', array('action' => 'index'), array('query' => array('type' => 2, 'job' => $job->jobid, 'client' => $job->clientname, 'restoreclient' => $job->clientname))); ?>"><span class="glyphicon glyphicon-import"></span> Restore job</a></li>
<?php endif; ?>
</ul>
</div>
Expand Down
23 changes: 19 additions & 4 deletions module/Restore/src/Restore/Controller/RestoreController.php
Expand Up @@ -81,6 +81,7 @@ public function indexAction()
array(
'query' => array(
'type' => $this->restore_params['type'],
'job' => $this->restore_params['job'],
'client' => $client,
'restoreclient' => $restoreclient,
'fileset' => $fileset,
Expand Down Expand Up @@ -144,6 +145,8 @@ public function queuedAction()
$this->getRestoreParams();

$result = $this->restore(
$this->restore_params['type'],
$this->restore_params['job'],
$this->restore_params['client'],
$this->restore_params['restoreclient'],
$this->restore_params['fileset'],
Expand Down Expand Up @@ -211,13 +214,25 @@ private function getRestoreParams()
/**
*
*/
private function restore($client=null, $restoreclient=null, $fileset=null, $where=null)
private function restore($type=null, $job=null, $client=null, $restoreclient=null, $fileset=null, $where=null)
{
$result = null;
$director = $this->getServiceLocator()->get('director');

$cmd = "restore client=$client restoreclient=$restoreclient fileset=$fileset where=$where current select all done yes";

$result = $director->send_command($cmd, 0);
switch ($type) {
// Restore most recent client (full)
case 1:
$cmd = "restore client=$client restoreclient=$restoreclient fileset=$fileset where=$where current select all done yes";
$result = $director->send_command($cmd, 0);
break;
// Restore specific job (jobid)
case 2:
$cmd = "restore jobid=$job client=$client restoreclient=$restoreclient where=$where all done yes";
$result = $director->send_command($cmd, 0);
break;
default:
break;
}

return $result;
}
Expand Down
6 changes: 6 additions & 0 deletions module/Restore/view/restore/restore/index.phtml
Expand Up @@ -44,13 +44,19 @@ $this->headTitle($title);

<?php
switch($this->restore_params['type']) {
// Restore most recent client (full)
case 1:
echo $this->formRow($form->get('client')->setAttribute('class','form-control'));
echo $this->formRow($form->get('fileset')->setAttribute('class','form-control'));
echo $this->formRow($form->get('restoreclient')->setAttribute('class','form-control'));
echo $this->formRow($form->get('where')->setAttribute('class','form-control'));
break;
// Restore specific job (jobid)
case 2:
echo $this->formRow($form->get('job')->setAttribute('class', 'form-control'));
echo $this->formRow($form->get('client')->setAttribute('class','form-control'));
echo $this->formRow($form->get('restoreclient')->setAttribute('class','form-control'));
echo $this->formRow($form->get('where')->setAttribute('class','form-control'));
break;
default:
echo $this->formRow($form->get('job')->setAttribute('class', 'form-control'));
Expand Down

0 comments on commit f92679e

Please sign in to comment.