Remove subjects from backup
This commit is contained in:
parent
d660936fac
commit
aead81fe1b
3 changed files with 35 additions and 48 deletions
|
@ -847,6 +847,10 @@
|
|||
</item>
|
||||
<item>
|
||||
<key>Choose a backup file</key>
|
||||
<value>AChoose a backup file</value>
|
||||
<value>Choose a backup file</value>
|
||||
</item>
|
||||
<item>
|
||||
<key>Restore status</key>
|
||||
<value>Restore status</value>
|
||||
</item>
|
||||
</translations>
|
|
@ -11,9 +11,9 @@
|
|||
{else}
|
||||
{assign var='status' value=$EXCHANGE->backupRestoreCheck()}
|
||||
|
||||
Backup status: {$status.status}
|
||||
##Restore status##: {if $status.status=='fault'}<b style="font-color:red">{$status.status}!!!</b>{else}{$status.status}{/if}
|
||||
|
||||
{if $status.status === 'success'}
|
||||
{if $status.status !== 'working'}
|
||||
<p><input type="button" class="button" value="##Close Backup Restore##" onCLick="location.href='{$UI_HANDLER}?act=RESTORE.backupRestoreClose'"></p>
|
||||
{/if}
|
||||
|
||||
|
|
|
@ -2,7 +2,8 @@
|
|||
define('BACKUP_EXT', 'tar');
|
||||
define('ACCESS_TYPE', 'backup');
|
||||
|
||||
class Backup {
|
||||
class Backup
|
||||
{
|
||||
/**
|
||||
* string - name of logfile
|
||||
*/
|
||||
|
@ -74,7 +75,8 @@ class Backup {
|
|||
*
|
||||
* @param gb: greenbox object reference
|
||||
*/
|
||||
function Backup (&$gb) {
|
||||
function Backup (&$gb)
|
||||
{
|
||||
$this->gb =& $gb;
|
||||
$this->token = null;
|
||||
$this->logFile = $this->gb->bufferDir.'/'.ACCESS_TYPE.'.log';
|
||||
|
@ -90,7 +92,8 @@ class Backup {
|
|||
* @return hasharray with field:
|
||||
* token string: backup token
|
||||
*/
|
||||
function openBackup($sessid,$criteria='') {
|
||||
function openBackup($sessid,$criteria='')
|
||||
{
|
||||
if ($this->loglevel=='debug') {
|
||||
$this->addLogItem("-I- ".date("Ymd-H:i:s")." openBackup - sessid:$sessid\n");
|
||||
}
|
||||
|
@ -125,8 +128,6 @@ class Backup {
|
|||
"/><!-- $ctime_f -->\n"
|
||||
);
|
||||
|
||||
file_put_contents("{$this->tmpDirMeta}/subjects.xml",$this->getSubjects());
|
||||
|
||||
# copy all file to tmpdir
|
||||
$this->copyAllFiles();
|
||||
|
||||
|
@ -147,7 +148,8 @@ class Backup {
|
|||
* url : string - access url
|
||||
* tmpfile : string - access filename
|
||||
*/
|
||||
function checkBackup($token) {
|
||||
function checkBackup($token)
|
||||
{
|
||||
if ($this->loglevel=='debug') {
|
||||
$this->addLogItem("-I- ".date("Ymd-H:i:s")." checkBackup - token:$token\n");
|
||||
}
|
||||
|
@ -173,7 +175,8 @@ class Backup {
|
|||
* @param token : token
|
||||
* @return status : boolean
|
||||
*/
|
||||
function closeBackup($token) {
|
||||
function closeBackup($token)
|
||||
{
|
||||
if ($this->loglevel=='debug') {
|
||||
$this->addLogItem("-I- ".date("Ymd-H:i:s")." closeBackup - token:$token\n");
|
||||
}
|
||||
|
@ -198,7 +201,8 @@ class Backup {
|
|||
* token : stirng - backup token
|
||||
* url : string - access url
|
||||
*/
|
||||
function listBackups($stat='') {
|
||||
function listBackups($stat='')
|
||||
{
|
||||
if ($this->loglevel=='debug') {
|
||||
$this->addLogItem("-I- ".date("Ymd-H:i:s")." listBackups - stat:$stat\n");
|
||||
}
|
||||
|
@ -219,7 +223,8 @@ class Backup {
|
|||
*
|
||||
* @param searchResult : array of gunids
|
||||
*/
|
||||
function setIDs($searchResult) {
|
||||
function setIDs($searchResult)
|
||||
{
|
||||
if ($this->loglevel=='debug') {
|
||||
$this->addLogItem("-I- ".date("Ymd-H:i:s")." setIDs\n");
|
||||
}
|
||||
|
@ -235,7 +240,8 @@ class Backup {
|
|||
* set the filenames from ids
|
||||
*
|
||||
*/
|
||||
function setFilenames () {
|
||||
function setFilenames ()
|
||||
{
|
||||
if ($this->loglevel=='debug') {
|
||||
$this->addLogItem("-I- ".date("Ymd-H:i:s")." setFilenames\n");
|
||||
}
|
||||
|
@ -275,7 +281,8 @@ class Backup {
|
|||
* Create the tarball - call the shell script
|
||||
*
|
||||
*/
|
||||
function doIt() {
|
||||
function doIt()
|
||||
{
|
||||
if ($this->loglevel=='debug') {
|
||||
$this->addLogItem("-I- ".date("Ymd-H:i:s")." doIt\n");
|
||||
}
|
||||
|
@ -295,7 +302,8 @@ class Backup {
|
|||
* Copy the real files into the tmp dirs to tar they.
|
||||
*
|
||||
*/
|
||||
function copyAllFiles() {
|
||||
function copyAllFiles()
|
||||
{
|
||||
if ($this->loglevel=='debug') {
|
||||
$this->addLogItem("-I- ".date("Ymd-H:i:s")." copyAllFiles\n");
|
||||
}
|
||||
|
@ -322,7 +330,8 @@ class Backup {
|
|||
* Figure out the enviroment to the backup
|
||||
*
|
||||
*/
|
||||
function setEnviroment($createDir=false) {
|
||||
function setEnviroment($createDir=false)
|
||||
{
|
||||
if ($this->loglevel=='debug') {
|
||||
$this->addLogItem("-I- ".date("Ymd-H:i:s")." setEnviroment - createDirs:$createDir\n");
|
||||
}
|
||||
|
@ -371,47 +380,20 @@ class Backup {
|
|||
* generate a new token.
|
||||
*
|
||||
*/
|
||||
function genToken() {
|
||||
function genToken()
|
||||
{
|
||||
$acc = $this->gb->bsAccess($this->tmpFile, BACKUP_EXT, null, ACCESS_TYPE);
|
||||
if($this->gb->dbc->isError($acc)){ return $acc; }
|
||||
$this->token = $acc['token'];
|
||||
}
|
||||
|
||||
/**
|
||||
* generate XML with subjects
|
||||
*
|
||||
* @return string : XML content
|
||||
*
|
||||
*/
|
||||
function getSubjects() {
|
||||
$subjs = $this->gb->getSubjects('id, login, pass, type, realname');
|
||||
$ret = "<subjects>\n";
|
||||
for ($i=0; $i<sizeof($subjs);$i++) {
|
||||
$tag = (strtolower($subjs[$i]['type'])=='g')?'group':'user';
|
||||
$ret .= " <{$tag}".
|
||||
" id=\"{$subjs[$i]['id']}\"" .
|
||||
" login=\"{$subjs[$i]['login']}\"" .
|
||||
" pass=\"{$subjs[$i]['pass']}\"" .
|
||||
" type=\"{$subjs[$i]['type']}\"" .
|
||||
" realname=\"{$subjs[$i]['realname']}\"" .
|
||||
">\n";
|
||||
$membof = $this->gb->_listRMemb($subjs[$i]['id']);
|
||||
$membs='';
|
||||
for ($j=0;$j<sizeof($membof);$j++) {
|
||||
$ret.=" <memberof id=\"{$membof[$j]['gid']}\" gid=\"{$membof[$j]['gid']}\" level=\"{$membof[$j]['gid']}\" />\n";
|
||||
}
|
||||
$ret .= " </{$tag}>\n";
|
||||
}
|
||||
$ret .= "</subjects>\n";
|
||||
return $ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a line to the logfile.
|
||||
*
|
||||
* @param item : string - the new row of log file
|
||||
*/
|
||||
function addLogItem($item) {
|
||||
function addLogItem($item)
|
||||
{
|
||||
$f = fopen ($this->logFile,'a');
|
||||
fwrite($f,$item);
|
||||
fclose($f);
|
||||
|
@ -423,7 +405,8 @@ class Backup {
|
|||
*
|
||||
* @param dirname : string - path of dir.
|
||||
*/
|
||||
function rRmDir($dirname) {
|
||||
function rRmDir($dirname)
|
||||
{
|
||||
if(is_dir($dirname))
|
||||
$dir_handle = opendir($dirname);
|
||||
while($file = readdir($dir_handle)) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue