diff --git a/module/Application/config/module.config.php b/module/Application/config/module.config.php index bd551539..f9f162bb 100644 --- a/module/Application/config/module.config.php +++ b/module/Application/config/module.config.php @@ -177,11 +177,11 @@ 'label' => 'Logs', 'route' => 'log', ), + /* array( 'label' => 'Restore', 'route' => 'restore', ), - /* array( 'label' => 'Statistics', 'route' => 'statistics', diff --git a/module/Client/view/client/client/index.phtml b/module/Client/view/client/client/index.phtml index c48f0ffb..dd3ed986 100644 --- a/module/Client/view/client/client/index.phtml +++ b/module/Client/view/client/client/index.phtml @@ -39,7 +39,7 @@ Clients per page: Autoprune Fileretention Jobretention - + Action paginator as $client) : ?> @@ -52,7 +52,30 @@ Clients per page: escapeHtml($client->autoprune); ?> printRetention($client->fileretention) . " days"; ?> printRetention($client->jobretention) . " days"; ?> - + +
+ + + +
+ diff --git a/module/Restore/src/Restore/Controller/RestoreController.php b/module/Restore/src/Restore/Controller/RestoreController.php index 9a631f35..1f5246d8 100644 --- a/module/Restore/src/Restore/Controller/RestoreController.php +++ b/module/Restore/src/Restore/Controller/RestoreController.php @@ -49,7 +49,7 @@ public function indexAction() $this->restore_params, $this->getJobs("long"), $this->getClients("long"), - null//$this->getFilesets("long") + $this->getFilesets("long") ); // Set the method attribute for the form @@ -64,6 +64,7 @@ public function indexAction() $form->setData( $request->getPost() ); if($form->isValid()) { + $job = $form->getInputFilter()->getValue('job'); $client = $form->getInputFilter()->getValue('client'); $restoreclient = $form->getInputFilter()->getValue('restoreclient'); @@ -71,7 +72,21 @@ public function indexAction() $before = $form->getInputFilter()->getValue('before'); $where = $form->getInputFilter()->getValue('where'); - return $this->redirect()->toRoute('restore', array('action' => 'confirm')); + return $this->redirect()->toRoute( + 'restore', + array( + 'controller'=>'restore', + 'action' => 'queued' + ), + array( + 'query' => array( + 'type' => $this->restore_params['type'], + 'client' => $client, + 'restoreclient' => $restoreclient, + 'fileset' => $fileset, + 'where' => $where + ) + )); } else { return new ViewModel(array( @@ -108,7 +123,10 @@ public function confirmAction() // 3. modify restore job // 4. cancel restore job - return new ViewModel(); + $this->getRestoreParams(); + + return new ViewModel( + ); } else { @@ -123,11 +141,18 @@ public function queuedAction() { if($_SESSION['bareos']['authenticated'] == true) { - // TODO + $this->getRestoreParams(); - // 1. display restore job queued + $result = $this->restore( + $this->restore_params['client'], + $this->restore_params['restoreclient'], + $this->restore_params['fileset'], + $this->restore_params['where'] + ); - return new ViewModel(); + return new ViewModel(array( + 'result' => $result + )); } else { @@ -174,6 +199,27 @@ private function getRestoreParams() else { $this->restore_params['fileset'] = null; } + + if($this->params()->fromQuery('where')) { + $this->restore_params['where'] = $this->params()->fromQuery('where'); + } + else { + $this->restore_params['where'] = null; + } + } + + /** + * + */ + private function restore($client=null, $restoreclient=null, $fileset=null, $where=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); + + return $result; } /** diff --git a/module/Restore/src/Restore/Form/RestoreForm.php b/module/Restore/src/Restore/Form/RestoreForm.php index 045ffc1c..a354be03 100644 --- a/module/Restore/src/Restore/Form/RestoreForm.php +++ b/module/Restore/src/Restore/Form/RestoreForm.php @@ -194,7 +194,7 @@ public function __construct($restore_params=null, $jobs=null, $clients=null, $fi 'label' => 'Where' ), 'attributes' => array( - 'value' => '/tmp/bareos-restore/' + 'value' => '/tmp/bareos-restores/' ) ) ); @@ -250,10 +250,9 @@ private function getFilesetList() $selectData = array(); if(!empty($this->filesets)) { foreach($this->filesets as $fileset) { - $selectData[$fileset['name']] = $fileset['name']; + $selectData[$fileset['fileset']] = $fileset['fileset']; } } - $selectData = array('fileset-1'=>'fileset-1'); return $selectData; } diff --git a/module/Restore/view/restore/restore/index.phtml b/module/Restore/view/restore/restore/index.phtml index b9ebb1c6..137ff127 100644 --- a/module/Restore/view/restore/restore/index.phtml +++ b/module/Restore/view/restore/restore/index.phtml @@ -48,6 +48,7 @@ $this->headTitle($title); 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; case 2: break; diff --git a/module/Restore/view/restore/restore/queued.phtml b/module/Restore/view/restore/restore/queued.phtml new file mode 100644 index 00000000..c4a66eac --- /dev/null +++ b/module/Restore/view/restore/restore/queued.phtml @@ -0,0 +1,42 @@ +. + * + */ + +$title = 'Restore'; +$this->headTitle($title); + +?> + +

+
+ +
+
+
+
+result; ?>
+
+
+
+