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

Commit

Permalink
Restore improvements
Browse files Browse the repository at this point in the history
Signed-off-by: Frank Bergkemper <frank.bergkemper@dass-it.de>
  • Loading branch information
fbergkemper committed Nov 18, 2015
1 parent 9467d56 commit f77ef94
Show file tree
Hide file tree
Showing 7 changed files with 122 additions and 47 deletions.
1 change: 0 additions & 1 deletion module/Job/src/Job/Controller/JobController.php
Expand Up @@ -40,7 +40,6 @@ public function indexAction()
{
if($_SESSION['bareos']['authenticated'] == true && $this->SessionTimeoutPlugin()->timeout()) {

$error = null;
$status = "all";
$period = 7;

Expand Down
6 changes: 3 additions & 3 deletions module/Job/src/Job/Form/JobForm.php
Expand Up @@ -46,7 +46,7 @@ public function __construct($period=null, $status=null)
'name' => 'period',
'type' => 'select',
'options' => array(
'label' => 'Period',
'label' => 'Time period',
'value_options' => array(
'1' => 'past 24 hours',
'7' => 'last week',
Expand All @@ -56,7 +56,7 @@ public function __construct($period=null, $status=null)
)
),
'attributes' => array(
'class' => 'selectpicker',
'class' => 'form-control selectpicker show-tick',
'data-size' => '5',
'id' => 'period',
'value' => $period
Expand All @@ -79,7 +79,7 @@ public function __construct($period=null, $status=null)
)
),
'attributes' => array(
'class' => 'selectpicker',
'class' => 'form-control selectpicker show-tick',
'data-size' => '5',
'id' => 'status',
'value' => $status
Expand Down
6 changes: 4 additions & 2 deletions module/Job/view/job/job/index.phtml
Expand Up @@ -98,10 +98,12 @@ $this->headTitle($title);
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
<h4 class="modal-title" id="myModalLabel">Oops, something went wrong.</h4>
<h4 class="modal-title" id="myModalLabel">Failed to retrieve data from Bareos director</h4>
</div>
<div class="modal-body">
<p>Director failed to send result as json. Maybe the result message is to long. Please reduce the period to display.</p>
<p>Please try to reduce the amount of data to display, e.g. reduce time period.</p>
<p>Error message received from director:</p>
<p class="text-danger">Failed to send result as json. Maybe result message to long?</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
Expand Down
14 changes: 10 additions & 4 deletions module/Restore/src/Restore/Controller/RestoreController.php
Expand Up @@ -45,6 +45,7 @@ public function indexAction()
if($_SESSION['bareos']['authenticated'] == true && $this->SessionTimeoutPlugin()->timeout()) {

$this->getRestoreParams();
$errors = null;

if($this->restore_params['client'] == null) {
$clients = $this->getRestoreModel()->getClients();
Expand Down Expand Up @@ -74,15 +75,19 @@ public function indexAction()
$backups = $this->getRestoreModel()->getClientBackups($this->restore_params['client'], "any", "desc");
}

$jobs = $this->getRestoreModel()->getJobs();
//$jobs = $this->getRestoreModel()->getJobs();
$clients = $this->getRestoreModel()->getClients();
$filesets = $this->getRestoreModel()->getFilesets();
$restorejobs = $this->getRestoreModel()->getRestoreJobs();

if($backups == null) {
$errors = 'No backups of client <strong>'.$this->restore_params['client'].'</strong> found.';
}

// Create the form
$form = new RestoreForm(
$this->restore_params,
$jobs,
//$jobs,
$clients,
$filesets,
$restorejobs,
Expand Down Expand Up @@ -129,15 +134,16 @@ public function indexAction()
else {
return new ViewModel(array(
'restore_params' => $this->restore_params,
'form' => $form
'form' => $form,
));
}

}
else {
return new ViewModel(array(
'restore_params' => $this->restore_params,
'form' => $form
'form' => $form,
'errors' => $errors
));
}

Expand Down
72 changes: 52 additions & 20 deletions module/Restore/src/Restore/Form/RestoreForm.php
Expand Up @@ -32,26 +32,27 @@ class RestoreForm extends Form
{

protected $restore_params;
protected $jobs;
//protected $jobs;
protected $clients;
protected $filesets;
protected $restorejobs;
protected $jobids;
protected $backups;

public function __construct($restore_params=null, $jobs=null, $clients=null, $filesets=null, $restorejobs=null, $jobids=null, $backups=null)
public function __construct($restore_params=null, /*$jobs=null,*/ $clients=null, $filesets=null, $restorejobs=null, $jobids=null, $backups=null)
{

parent::__construct('restore');

$this->restore_params = $restore_params;
$this->jobs = $jobs;
//$this->jobs = $jobs;
$this->clients = $clients;
$this->filesets = $filesets;
$this->restorejobs = $restorejobs;
$this->jobids = $jobids;
$this->backups = $backups;

/*
// Job
if(isset($restore_params['jobid'])) {
$this->add(array(
Expand Down Expand Up @@ -82,18 +83,21 @@ public function __construct($restore_params=null, $jobs=null, $clients=null, $fi
)
));
}
*/

// Backup
// Backup jobs
if(isset($restore_params['jobid'])) {
$this->add(array(
'name' => 'backups',
'type' => 'select',
'options' => array(
'label' => 'Backups',
'empty_option' => 'Please choose a backup',
'label' => 'Backup jobs',
//'empty_option' => 'Please choose a backup',
'value_options' => $this->getBackupList()
),
'attributes' => array(
'class' => 'form-control selectpicker show-tick',
'data-live-search' => 'true',
'id' => 'jobid',
'value' => $restore_params['jobid']
)
Expand All @@ -105,10 +109,12 @@ public function __construct($restore_params=null, $jobs=null, $clients=null, $fi
'type' => 'select',
'options' => array(
'label' => 'Backups',
'empty_option' => 'Please choose a backup',
//'empty_option' => 'Please choose a backup',
'value_options' => $this->getBackupList()
),
'attributes' => array(
'class' => 'form-control selectpicker show-tick',
'data-live-search' => 'true',
'id' => 'jobid'
)
));
Expand All @@ -122,10 +128,12 @@ public function __construct($restore_params=null, $jobs=null, $clients=null, $fi
'type' => 'select',
'options' => array(
'label' => 'Client',
'empty_option' => 'Please choose a client',
//'empty_option' => 'Please choose a client',
'value_options' => $this->getClientList()
),
'attributes' => array(
'class' => 'form-control selectpicker show-tick',
'data-live-search' => 'true',
'id' => 'client',
'value' => $restore_params['client']
)
Expand All @@ -137,10 +145,12 @@ public function __construct($restore_params=null, $jobs=null, $clients=null, $fi
'type' => 'select',
'options' => array(
'label' => 'Client',
'empty_option' => 'Please choose a client',
//'empty_option' => 'Please choose a client',
'value_options' => $this->getClientList()
),
'attributes' => array(
'class' => 'form-control selectpicker show-tick',
'data-live-search' => 'true',
'id' => 'client',
'value' => $restore_params['client']
)
Expand All @@ -153,10 +163,12 @@ public function __construct($restore_params=null, $jobs=null, $clients=null, $fi
'type' => 'select',
'options' => array(
'label' => 'Client',
'empty_option' => 'Please choose a client',
//'empty_option' => 'Please choose a client',
'value_options' => $this->getClientList()
),
'attributes' => array(
'class' => 'form-control selectpicker show-tick',
'data-live-search' => 'true',
'id' => 'client',
'value' => @array_pop($this->getClientList())
)
Expand All @@ -169,11 +181,13 @@ public function __construct($restore_params=null, $jobs=null, $clients=null, $fi
'name' => 'restoreclient',
'type' => 'select',
'options' => array(
'label' => 'Restore to client',
'empty_option' => 'Please choose a client',
'label' => 'Restore to (another) client',
//'empty_option' => 'Please choose a client',
'value_options' => $this->getClientList()
),
'attributes' => array(
'class' => 'form-control selectpicker show-tick',
'data-live-search' => 'true',
'id' => 'restoreclient',
'value' => $restore_params['restoreclient']
)
Expand All @@ -184,11 +198,13 @@ public function __construct($restore_params=null, $jobs=null, $clients=null, $fi
'name' => 'restoreclient',
'type' => 'select',
'options' => array(
'label' => 'Restore to client',
'empty_option' => 'Please choose a client',
'label' => 'Restore to (another) client',
//'empty_option' => 'Please choose a client',
'value_options' => $this->getClientList()
),
'attributes' => array(
'class' => 'form-control selectpicker show-tick',
'data-live-search' => 'true',
'id' => 'restoreclient',
'value' => $restore_params['client']
)
Expand All @@ -199,11 +215,13 @@ public function __construct($restore_params=null, $jobs=null, $clients=null, $fi
'name' => 'restoreclient',
'type' => 'select',
'options' => array(
'label' => 'Restore to another client',
'empty_option' => 'Please choose a client',
'label' => 'Restore to (another) client',
//'empty_option' => 'Please choose a client',
'value_options' => $this->getClientList()
),
'attributes' => array(
'class' => 'form-control selectpicker show-tick',
'data-live-search' => 'true',
'id' => 'restoreclient'
)
));
Expand Down Expand Up @@ -247,10 +265,12 @@ public function __construct($restore_params=null, $jobs=null, $clients=null, $fi
'type' => 'select',
'options' => array(
'label' => 'Restore job',
'empty_option' => 'Please choose a restore job',
//'empty_option' => 'Please choose a restore job',
'value_options' => $this->getRestoreJobList()
),
'attributes' => array(
'class' => 'form-control selectpicker show-tick',
'data-live-search' => 'true',
'id' => 'restorejob',
'value' => $restore_params['restorejob']
)
Expand All @@ -263,10 +283,12 @@ public function __construct($restore_params=null, $jobs=null, $clients=null, $fi
'type' => 'select',
'options' => array(
'label' => 'Restore job',
'empty_option' => 'Please choose a restore job',
//'empty_option' => 'Please choose a restore job',
'value_options' => $this->getRestoreJobList()
),
'attributes' => array(
'class' => 'form-control selectpicker show-tick',
'data-live-search' => 'true',
'id' => 'restorejob',
'value' => @array_pop($this->getRestoreJobList())
)
Expand All @@ -278,10 +300,12 @@ public function __construct($restore_params=null, $jobs=null, $clients=null, $fi
'type' => 'select',
'options' => array(
'label' => 'Restore job',
'empty_option' => 'Please choose a restore job',
//'empty_option' => 'Please choose a restore job',
'value_options' => $this->getRestoreJobList()
),
'attributes' => array(
'class' => 'form-control selectpicker show-tick',
'data-live-search' => 'true',
'id' => 'restorejob'
)
));
Expand All @@ -301,6 +325,7 @@ public function __construct($restore_params=null, $jobs=null, $clients=null, $fi
)
),
'attributes' => array(
'class' => 'form-control selectpicker show-tick',
'id' => 'mergefilesets',
'value' => $restore_params['mergefilesets']
)
Expand All @@ -319,6 +344,7 @@ public function __construct($restore_params=null, $jobs=null, $clients=null, $fi
)
),
'attributes' => array(
'class' => 'form-control selectpicker show-tick',
'id' => 'mergefilesets',
'value' => '0'
)
Expand All @@ -332,13 +358,14 @@ public function __construct($restore_params=null, $jobs=null, $clients=null, $fi
'name' => 'mergejobs',
'type' => 'select',
'options' => array(
'label' => 'Merge jobs?',
'label' => 'Merge all related jobs to last full backup of selected backup job?',
'value_options' => array(
'0' => 'Yes',
'1' => 'No'
)
),
'attributes' => array(
'class' => 'form-control selectpicker show-tick',
'id' => 'mergejobs',
'value' => $restore_params['mergejobs']
)
Expand All @@ -357,6 +384,7 @@ public function __construct($restore_params=null, $jobs=null, $clients=null, $fi
)
),
'attributes' => array(
'class' => 'form-control selectpicker show-tick',
'id' => 'mergejobs',
'value' => '0'
)
Expand All @@ -378,6 +406,7 @@ public function __construct($restore_params=null, $jobs=null, $clients=null, $fi
)
),
'attributes' => array(
'class' => 'form-control selectpicker show-tick',
'id' => 'replace',
'value' => 'never'
)
Expand All @@ -392,6 +421,7 @@ public function __construct($restore_params=null, $jobs=null, $clients=null, $fi
'label' => 'Restore location on client'
),
'attributes' => array(
'class' => 'form-control selectpicker show-tick',
'value' => '/tmp/bareos-restores/',
'id' => 'where',
'size' => '30',
Expand Down Expand Up @@ -481,6 +511,7 @@ private function getBackupList()
{
$selectData = array();
if(!empty($this->backups)) {

foreach($this->backups as $backup) {
switch($backup['level']) {
case 'I':
Expand Down Expand Up @@ -518,6 +549,7 @@ private function getClientList()
$selectData[$client['name']] = $client['name'];
}
}
ksort($selectData);
return $selectData;
}

Expand Down

0 comments on commit f77ef94

Please sign in to comment.