Restore part of #1608
This commit is contained in:
parent
79e5acb683
commit
e92f5b3d34
9 changed files with 156 additions and 23 deletions
|
@ -160,15 +160,17 @@ if (is_array($_REQUEST['popup'])){
|
||||||
$Smarty->display('popup/help.tpl');
|
$Smarty->display('popup/help.tpl');
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "BACKUP.setLocation":
|
case 'BACKUP.setLocation':
|
||||||
if ($_REQUEST['cd']) {
|
if ($_REQUEST['cd']) {
|
||||||
$uiBrowser->EXCHANGE->setFolder($_REQUEST['cd']);
|
$uiBrowser->EXCHANGE->setFolder($_REQUEST['cd']);
|
||||||
}
|
}
|
||||||
|
$Smarty->assign('isRestore',$_REQUEST['isRestore']);
|
||||||
$Smarty->display('backup/fileBrowser.tpl');
|
$Smarty->display('backup/fileBrowser.tpl');
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'BACKUP.setFile':
|
case 'BACKUP.setFile':
|
||||||
$uiBrowser->EXCHANGE->setFile($_REQUEST['file']);
|
$Smarty->assign('isFile',$uiBrowser->EXCHANGE->setFile($_REQUEST['file']));
|
||||||
|
$Smarty->assign('isRestore',$_REQUEST['isRestore']);
|
||||||
$Smarty->display('backup/fileBrowser.tpl');
|
$Smarty->display('backup/fileBrowser.tpl');
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
|
@ -371,7 +371,7 @@ switch($_REQUEST['act']){
|
||||||
$uiHandler->SCHEDULER->setReload();
|
$uiHandler->SCHEDULER->setReload();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "BACKUP.createBackupOpen":
|
case 'BACKUP.createBackupOpen':
|
||||||
$uiHandler->EXCHANGE->createBackupOpen();
|
$uiHandler->EXCHANGE->createBackupOpen();
|
||||||
$uiHandler->redirUrl = UI_BROWSER.'?act=BACKUP';
|
$uiHandler->redirUrl = UI_BROWSER.'?act=BACKUP';
|
||||||
break;
|
break;
|
||||||
|
@ -381,12 +381,22 @@ switch($_REQUEST['act']){
|
||||||
$uiHandler->redirUrl = UI_BROWSER.'?act=BACKUP';
|
$uiHandler->redirUrl = UI_BROWSER.'?act=BACKUP';
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "BACKUP.createBackupClose":
|
case 'BACKUP.createBackupClose':
|
||||||
$uiHandler->EXCHANGE->createBackupClose();
|
$uiHandler->EXCHANGE->createBackupClose();
|
||||||
$uiHandler->redirUrl = UI_BROWSER.'?act=BACKUP';
|
$uiHandler->redirUrl = UI_BROWSER.'?act=BACKUP';
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "SESSION.CLEAR":
|
case 'RESTORE.setBackupFileToRestore':
|
||||||
|
$uiHandler->EXCHANGE->backupRestoreOpen($_REQUEST['target']);
|
||||||
|
$uiHandler->redirUrl = UI_BROWSER.'?act=RESTORE';
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'RESTORE.backupRestoreClose':
|
||||||
|
$uiHandler->EXCHANGE->backupRestoreClose();
|
||||||
|
$uiHandler->redirUrl = UI_BROWSER.'?act=RESTORE';
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'SESSION.CLEAR':
|
||||||
$_SESSION = array();
|
$_SESSION = array();
|
||||||
die();
|
die();
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -845,4 +845,8 @@
|
||||||
<key>Are you sure to cancel transfer(s)?</key>
|
<key>Are you sure to cancel transfer(s)?</key>
|
||||||
<value>Are you sure to cancel transfer(s)?</value>
|
<value>Are you sure to cancel transfer(s)?</value>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<key>Choose a backup file</key>
|
||||||
|
<value>AChoose a backup file</value>
|
||||||
|
</item>
|
||||||
</translations>
|
</translations>
|
|
@ -17,10 +17,18 @@ if (window.scrollbars.visible == false) {
|
||||||
<tr><td colspan=""><h1>##File browser##</h1></td></tr>
|
<tr><td colspan=""><h1>##File browser##</h1></td></tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="6" style="white-space: nowrap;">
|
<td colspan="6" style="white-space: nowrap;">
|
||||||
<form name="filebrowser" onSubmit="opener.location.href='{$UI_HANDLER}?act=BACKUP.copy2target&target='+filebrowser.target.value; window.close()">
|
<form name="filebrowser"
|
||||||
|
{if !$isRestore}
|
||||||
|
onSubmit="opener.location.href='{$UI_HANDLER}?act=BACKUP.copy2target&target='+filebrowser.target.value; window.close()"
|
||||||
|
{else}
|
||||||
|
onSubmit="opener.location.href='{$UI_HANDLER}?act=RESTORE.setBackupFileToRestore&target='+filebrowser.target.value; window.close()"
|
||||||
|
{/if}
|
||||||
|
>
|
||||||
##Filename:## <br>
|
##Filename:## <br>
|
||||||
<input type='text' name='target' size='50' value='{$EXCHANGE->getPath()}'>
|
<input type='text' name='target' size='50' value='{$EXCHANGE->getPath()}'>
|
||||||
|
{if ($isRestore && $isFile) || !$isRestore}
|
||||||
<input type='submit' class='button' value='##OK##'>
|
<input type='submit' class='button' value='##OK##'>
|
||||||
|
{/if}
|
||||||
</form>
|
</form>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
@ -28,7 +36,7 @@ if (window.scrollbars.visible == false) {
|
||||||
|
|
||||||
{foreach from=$currdir.subdirs item=entry key=name}
|
{foreach from=$currdir.subdirs item=entry key=name}
|
||||||
<tr class="{cycle values='blue1, blue2'}">
|
<tr class="{cycle values='blue1, blue2'}">
|
||||||
<td style="border-right: 1px solid #333;"><b><a href="{$UI_BROWSER}?popup[]=BACKUP.setLocation&cd={$name|escape:"url"}">{$name|truncate:50:"...":true}</b></td>
|
<td style="border-right: 1px solid #333;"><b><a href="{$UI_BROWSER}?popup[]=BACKUP.setLocation{if $isRestore}&isRestore=1{/if}&cd={$name|escape:"url"}">{$name|truncate:50:"...":true}</b></td>
|
||||||
<td style="border-right: 1px solid #333;">{$entry.u|truncate:10:'...':true}</td>
|
<td style="border-right: 1px solid #333;">{$entry.u|truncate:10:'...':true}</td>
|
||||||
<td style="border-right: 1px solid #333;">{$entry.g|truncate:10:'...':true}</td>
|
<td style="border-right: 1px solid #333;">{$entry.g|truncate:10:'...':true}</td>
|
||||||
<td style="border-right: 1px solid #333;">{if $entry.r}r{/if}</td>
|
<td style="border-right: 1px solid #333;">{if $entry.r}r{/if}</td>
|
||||||
|
@ -40,7 +48,7 @@ if (window.scrollbars.visible == false) {
|
||||||
|
|
||||||
{foreach from=$currdir.files item=entry key=name}
|
{foreach from=$currdir.files item=entry key=name}
|
||||||
<tr class="{cycle values='blue1, blue2'}">
|
<tr class="{cycle values='blue1, blue2'}">
|
||||||
<td style="border-right: 1px solid #333;"><a href="{$UI_BROWSER}?popup[]=BACKUP.setFile&file={$name|escape:"url"}">{$name|truncate:50:"...":true}</td>
|
<td style="border-right: 1px solid #333;"><a href="{$UI_BROWSER}?popup[]=BACKUP.setFile{if $isRestore}&isRestore=1{/if}&file={$name|escape:"url"}">{$name|truncate:50:"...":true}</td>
|
||||||
<td style="border-right: 1px solid #333;">{$entry.u|truncate:10:'...':true}</td>
|
<td style="border-right: 1px solid #333;">{$entry.u|truncate:10:'...':true}</td>
|
||||||
<td style="border-right: 1px solid #333;">{$entry.g|truncate:10:'...':true}</td>
|
<td style="border-right: 1px solid #333;">{$entry.g|truncate:10:'...':true}</td>
|
||||||
<td style="border-right: 1px solid #333;">{if $entry.r}r{/if}</td>
|
<td style="border-right: 1px solid #333;">{if $entry.r}r{/if}</td>
|
||||||
|
|
|
@ -3,21 +3,23 @@
|
||||||
<div class="container_elements" style="width: 607px;">
|
<div class="container_elements" style="width: 607px;">
|
||||||
<h1>##Restore backup##</h1>
|
<h1>##Restore backup##</h1>
|
||||||
|
|
||||||
{assign var=token' value=$EXCHANGE->getBackupToken()}
|
{assign var='token' value=$EXCHANGE->getRestoreToken()}
|
||||||
|
|
||||||
{if $token === false}
|
{if $token === false}
|
||||||
<input type="button" value="##Start backup##" onClick="location.href='{$UI_HANDLER}?act=EXCHANGE.createBackupOpen'">
|
<input type="button" class="button_large" value="##Choose backup file##" onClick="popup('{$UI_BROWSER}?popup[]=BACKUP.setLocation&isRestore=1', 'RESTORE.backupFile', 600, 600)">
|
||||||
|
|
||||||
{else}
|
{else}
|
||||||
{assign var='status' value=$EXCHANGE->createBackupCheck()}
|
{assign var='status' value=$EXCHANGE->backupRestoreCheck()}
|
||||||
|
|
||||||
Backup status: {$status.status}
|
Backup status: {$status.status}
|
||||||
|
|
||||||
{if $status.status === 'success'}
|
{if $status.status === 'success'}
|
||||||
<p><input type="button" class="button" value="##Download##" onCLick="hpopup('{$status.tmpfile}')"></p>
|
<p><input type="button" class="button" value="##Close Backup Restore##" onCLick="location.href='{$UI_HANDLER}?act=RESTORE.backupRestoreClose'"></p>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -110,6 +110,7 @@ define('UI_PL_ELEM_FADEOUT', 'fadeOut');
|
||||||
|
|
||||||
## Export/Import
|
## Export/Import
|
||||||
define('UI_BACKUPTOKEN_KEY', 'backupToken');
|
define('UI_BACKUPTOKEN_KEY', 'backupToken');
|
||||||
|
define('UI_RESTORETOKEN_KEY', 'restoreToken');
|
||||||
|
|
||||||
## LS stuff
|
## LS stuff
|
||||||
require_once '../../../storageServer/var/conf.php';
|
require_once '../../../storageServer/var/conf.php';
|
||||||
|
|
|
@ -11,7 +11,7 @@ class uiExchange
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// GB wrapper emthods
|
// GB wrapper methods
|
||||||
|
|
||||||
function getBackupToken()
|
function getBackupToken()
|
||||||
{
|
{
|
||||||
|
@ -47,7 +47,7 @@ class uiExchange
|
||||||
$token = $this->getBackupToken();
|
$token = $this->getBackupToken();
|
||||||
|
|
||||||
if ($token === false) {
|
if ($token === false) {
|
||||||
return flase;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$res = $this->Base->gb->createBackupCheck($token);
|
$res = $this->Base->gb->createBackupCheck($token);
|
||||||
|
@ -76,7 +76,7 @@ class uiExchange
|
||||||
|
|
||||||
function createBackupClose()
|
function createBackupClose()
|
||||||
{
|
{
|
||||||
$token = $token = $this->getBackupToken();
|
$token = $this->getBackupToken();
|
||||||
|
|
||||||
if ($token === false) {
|
if ($token === false) {
|
||||||
$this->Base->_retMsg('Token not available');
|
$this->Base->_retMsg('Token not available');
|
||||||
|
@ -144,7 +144,79 @@ class uiExchange
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Restore methods
|
||||||
|
function getRestoreToken()
|
||||||
|
{
|
||||||
|
$token = $this->Base->gb->loadPref($this->Base->sessid, UI_RESTORETOKEN_KEY);
|
||||||
|
if (PEAR::isError($token)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return $token;
|
||||||
|
}
|
||||||
|
|
||||||
|
function restore($filename) {
|
||||||
|
$filename='/tmp/backup_20060508.tar';
|
||||||
|
}
|
||||||
|
|
||||||
|
function backupRestoreOpen($backupFile)
|
||||||
|
{
|
||||||
|
$token = $this->Base->gb->backupRestoreOpen($this->Base->sessid,$backupFile);
|
||||||
|
|
||||||
|
if (PEAR::isError($token)) {
|
||||||
|
$this->Base->_retMsg('Error initializing backup restore: $1', $token->getMessage());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
#$this->backupRestoreCheck(); //?
|
||||||
|
|
||||||
|
$this->Base->gb->savePref($this->Base->sessid, UI_RESTORETOKEN_KEY, $token['token']);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
function backupRestoreCheck()
|
||||||
|
{
|
||||||
|
$token = $this->getRestoreToken();
|
||||||
|
|
||||||
|
if ($token === false) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
$res = $this->Base->gb->backupRestoreCheck($token);
|
||||||
|
|
||||||
|
if (PEAR::isError($res)) {
|
||||||
|
$this->Base->_retMsg('Unable to check backup restore status: $1', $res->getMessage());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $res;
|
||||||
|
}
|
||||||
|
|
||||||
|
function backupRestoreClose()
|
||||||
|
{
|
||||||
|
$token = $this->getRestoreToken();
|
||||||
|
|
||||||
|
if ($token === false) {
|
||||||
|
$this->Base->_retMsg('Backup restore token is not available');
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
$status = $this->Base->gb->backupRestoreClose($token);
|
||||||
|
|
||||||
|
if (PEAR::isError($status)) {
|
||||||
|
$this->Base->_retMsg('Error closing restore backup: $1', $status->getMessage());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($status === true) {
|
||||||
|
$this->Base->gb->delPref($this->Base->sessid, UI_RESTORETOKEN_KEY);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $status;
|
||||||
|
}
|
||||||
|
|
||||||
|
function setBackupFileToRestore($filename) {
|
||||||
|
}
|
||||||
|
|
||||||
// file browser methods
|
// file browser methods
|
||||||
|
|
||||||
|
@ -248,11 +320,5 @@ class uiExchange
|
||||||
);
|
);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// restore methods
|
|
||||||
function restore($filename) {
|
|
||||||
$filename='/tmp/backup_20060508.tar';
|
|
||||||
$this->Base->gb->doRestore($this->Base->sessid,$filename);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
?>
|
?>
|
40
livesupport/src/modules/storageServer/bin/restore.php
Executable file
40
livesupport/src/modules/storageServer/bin/restore.php
Executable file
|
@ -0,0 +1,40 @@
|
||||||
|
#!/usr/bin/php
|
||||||
|
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Do database restore in background. - command line php application
|
||||||
|
*
|
||||||
|
* required command line parameters:
|
||||||
|
* @param 1. backup file
|
||||||
|
* @param 2. status file
|
||||||
|
* @param 3. token
|
||||||
|
* @param 4. sessid
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
require_once dirname(__FILE__).'/../var/conf.php';
|
||||||
|
require_once dirname(__FILE__).'/../var/GreenBox.php';
|
||||||
|
require_once dirname(__FILE__).'/../var/Restore.php';
|
||||||
|
include_once 'DB.php';
|
||||||
|
|
||||||
|
$dbc = DB::connect($config['dsn'], TRUE);
|
||||||
|
if (DB::isError($dbc)) {
|
||||||
|
die($dbc->getMessage());
|
||||||
|
}
|
||||||
|
$dbc->setFetchMode(DB_FETCHMODE_ASSOC);
|
||||||
|
|
||||||
|
$gb =& new GreenBox($dbc, $config);
|
||||||
|
$rs = new Restore($gb);
|
||||||
|
|
||||||
|
if ($rs->loglevel=='debug') {
|
||||||
|
$rs->addLogItem('argv:'.print_r($argv,true));
|
||||||
|
}
|
||||||
|
|
||||||
|
# sleep(2);
|
||||||
|
|
||||||
|
$backupfile = $argv[1];
|
||||||
|
$token = $argv[3];
|
||||||
|
$sessid = $argv[4];
|
||||||
|
$rs->startRestore($backupfile,$token,$sessid);
|
||||||
|
|
||||||
|
?>
|
|
@ -294,7 +294,7 @@ class Restore {
|
||||||
if(!is_dir($dirname."/".$file))
|
if(!is_dir($dirname."/".$file))
|
||||||
unlink ($dirname."/".$file);
|
unlink ($dirname."/".$file);
|
||||||
else
|
else
|
||||||
Backup::rRmDir($dirname."/".$file);
|
Restore::rRmDir($dirname."/".$file);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
closedir($dir_handle);
|
closedir($dir_handle);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue