function mebackup_main() { global $gbl, $sgbl, $login, $ghtml; $progname = $sgbl->__var_program_name; $cprogname = ucfirst($progname); initProgram('admin'); lxfile_mkdir("__path_program_home/selfbackup/self/__backup"); $backup = $login->getObject('general')->selfbackupparam_b; $dbf = $sgbl->__var_dbf; $pass = trim(lfile_get_contents("__path_program_root/etc/conf/{$progname}.pass")); $vd = createTempDir("/tmp", "mebackup"); $docf = "{$vd}/mebackup.dump"; // Issue #671 - Fixed backup-restore issue // exec("exec mysqldump --add-drop-table -u $progname -p$pass $dbf > $docf"); system("exec mysqldump --add-drop-table -u {$progname} -p{$pass} {$dbf} > {$docf}"); $string = @date('Y-M-d') . '-' . time(); $bfile = "{$sgbl->__path_program_home}/selfbackup/self/__backup/{$progname}-scheduled-masterselfbackup-{$string}.zip"; lxshell_zip($vd, $bfile, array("mebackup.dump")); lxfile_tmp_rm_rec($vd); if ($backup && $backup->isOn('selfbackupflag')) { try { lxbackup::upload_to_server($bfile, basename($bfile), $backup); } catch (Exception $e) { print "Sending warning to {$login->contactemail} ..\n"; lx_mail(null, $login->contactemail, "{$cprogname} Self Database Backup Upload Failed on " . date('Y-M-d') . " at " . date('H') . " Hours", "{$cprogname} Backup upload Failed due to {$e->getMessage()}\n"); } } $backup->rm_last_number = 20; $backup->nname = 'masterselfbackup'; lxbackup::clear_extra_backups('selfbackup', 'self', $backup); }
static function getMetaData($file) { global $gbl, $sgbl, $login, $ghtml; $progname = $sgbl->__var_program_name; if (!lxfile_exists($file)) { throw new lxException('could_not_find_file', '', $file); } $tmpdir = lxbackup::createTmpDirIfitDoesntExist($file, false); print_time("create_tmp_dir", "Creating Tmp Directory"); $filename = recursively_get_file($tmpdir, "{$progname}.file"); // KLoxo has to recognize lxadmin's backup file. if (!$filename && $sgbl->isKloxoForRestore()) { $filename = recursively_get_file($tmpdir, "lxadmin.file"); } $rem = unserialize(file_get_contents($filename)); lxfile_tmp_rm_rec($tmpdir); if (!$rem) { throw new lxException('backupfile_corrupted', ''); } return $rem; }
function doCoreRestore($bfile, $param) { global $gbl, $sgbl, $login, $ghtml; $progname = $sgbl->__var_program_name; $cprogname = ucfirst($progname); $vd = lxbackup::createTmpDirIfitDoesntExist($bfile, true); if ($sgbl->isKloxo()) { try { $file = "{$vd}/{$progname}.file"; $rem = getObjectFromFileWithThrow($file); $ob = $rem->bobject; } catch (Exception $e) { $file = "{$vd}/lxadmin.file"; $rem = getObjectFromFileWithThrow($file); $ob = $rem->bobject; } } else { $file = "{$vd}/{$progname}.file"; $rem = getObjectFromFileWithThrow($file); $ob = $rem->bobject; } dprint($ob->getClName()); dprint($this->getClName()); if ($ob->getClName() !== $this->getClName()) { throw new lxException('objectclassname_doesnt_match', ''); } $gbl->__var_serverlist = $param['switchserverlist']; if ($gbl->__var_list_flag) { print "Contents of the backfile: Owner: {$ob->nname}.....\n"; } else { print "Restoring backup for {$ob->nname}.....\n"; } try { $ob->checkForConsistency(null, $param['_accountselect'], true); } catch (Exception $e) { lxfile_tmp_rm_rec($vd); throw $e; } // Restore the currenct client's quota. The person who is doing the restoring souldn't able to escape his new quota. if ($this->isLogin()) { $ob->priv = $this->priv; if (isset($this->listpriv)) { $ob->listpriv = $this->listpriv; } if (isset($this->dnstemplate_list)) { $ob->dnstemplate_list = $this->dnstemplate_list; } } try { if (!$gbl->__var_list_flag) { $ob->was(); foreach ($sgbl->__var_objectrestorelist as $d) { $d->restoreMeUp($vd, $rem->ddate); } } } catch (Exception $e) { lxfile_tmp_rm_rec($vd); throw $e; } lxfile_tmp_rm_rec($vd); }