function consistencyAlreadyExisting($res, $trulist, $real) { global $gbl, $sgbl, $login, $ghtml; $pclname = $res[0]['parent_clname']; if ($pclname != $this->parent_clname) { list($parentclass, $parentname) = getClassAndName($pclname); if ($real) { $this->dbaction = 'already_present_under_different_owner'; } if ($login->isAdmin()) { $parentstring = "{$parentclass}:{$parentname}"; } else { $parentstring = "Someone Else"; } $this->AddMEssageOnlyIfClientDomain("<font color=red><b> (Already Present under {$parentstring}. Will Not be Restored)</font> </b> "); if ($this->isCoreBackup()) { log_restore("{$this->get__table()}:{$this->nname} is already present under another user. Won't be restored"); } return false; } if (isset($res[0]['syncserver']) && $this->syncserver !== $res[0]['syncserver']) { $string = "Server for {$this->get__table()}:{$this->nname} in the backup is {$this->syncserver} but in the database is {$res[0]['syncserver']}. Using the one in Database\n"; $this->syncserver = $res[0]['syncserver']; $this->createSyncClass(); print $string; log_restore($string); } $class = $this->get__table(); $existobj = new $class($this->__masterserver, $this->syncserver, $this->nname); $existobj->get(); $cl = $existobj->getChildListFilter(null); foreach ((array) $cl as $c) { if (cse($c, "_a")) { $this->AddToArrayObjectList($c, $existobj->{$c}); } } if ($real) { if ($gbl->__var_list_flag) { if ($this->isCoreBackup()) { print "{$this->getClName()} under {$this->__parent_o->nname} Already exists.....\n"; } } else { $this->setUpdateSubaction('full_update'); if ($this->isCoreBackup()) { print "{$this->getClName()} under {$this->__parent_o->nname} Already exists... Updating.....\n"; } } } $extra = null; if ($trulist) { $extra = " Will be Updated"; } $this->AddMEssageOnlyIfClientDomain("<b> (Already Exists.{$extra}). </b>"); if ($this->extraRestore()) { $sgbl->__var_objectrestorelist[] = $this; } $this->__var_checked = true; return true; }
public function do_restore($docd) { global $gbl, $sgbl, $login, $ghtml; $this->hardstop(); $this->createDisk(); $tmpbasedir = $this->main->__var_tmp_base_dir; if ($this->checkForSnapshot()) { lvm_remove($this->getSnapshotName()); if ($this->checkForSnapshot()) { throw new lxException("snapshot_for_this_exists_and_coudnt_remove"); } } if (!$this->main->isWindows()) { $mountpoint = $this->mount_this_guy(); lxshell_unzip_numeric_with_throw($mountpoint, $docd); //lxshell_return("tar", "-C", "$mountpoint/dev", "-xzf", "__path_program_root/file/vps-dev.tgz"); if ($this->main->__old_driver !== 'xen') { log_restore("Restoring {$this->main->nname} from a different driver {$this->main->__old_driver} to xen"); /* if (!lxfile_exists("__path_program_home/xen/template/{$this->main->ostemplate}.tar.gz")) { throw new lxException("migrating_from_{$this->main->__old_driver}_needs_osImage"); } */ //lxshell_return("tar", "-C", $mountpoint, "-xzf", "__path_program_home/xen/template/{$this->main->ostemplate}.tar.gz", "etc/rc.d", "sbin", "etc/hotplug.d", "etc/dev.d", "etc/udev", "lib", "usr", "bin", "etc/inittab", "etc/sysconfig"); //lxshell_return("tar", "-C", $mountpoint, "-xzf", "__path_program_home/xen/template/{$this->main->ostemplate}.tar.gz", "etc/rc.d", "sbin", "etc/hotplug.d", "etc/dev.d", "etc/udev", "lib", "usr", "bin", "etc/inittab"); lxfile_cp("../file/sysfile/xen/fstab", "{$mountpoint}/etc/fstab"); lxfile_cp("__path_program_root/file/sysfile/xen/inittab", "{$mountpoint}/etc/inittab"); lunlink("{$mountpoint}/etc/mtab"); lunlink("{$mountpoint}/etc/init.d/vzquota"); $this->copyKernelModules(); } lxfile_mkdir("{$mountpoint}/proc"); $this->createConfig(); $this->setMemoryUsage(); $this->setCpuUsage(); $this->setSwapUsage(); } else { $tmpdir = createTempDir($tmpbasedir, "lx_{$this->main->nname}_backup"); lxshell_unzip_with_throw($tmpdir, $docd); $partition = $this->getPartition(); lxshell_return("ntfsclone", "--restore-image", "--force", "-O", $partition, "{$tmpdir}/backup.img"); lxfile_tmp_rm_rec("{$tmpdir}"); $this->kpart_remove(); } $this->main->status = 'on'; try { $this->toggleStatus(); } catch (Exception $e) { } $this->start(); // Saving state doesn't seem to be an option. The thing is, it is the file system itself that's left in an inconsistent state, and there's little we can do about it. /* $statefile = "$mountpoint/__hypervm_xensavestate"; if (lxfile_exists($statefile)) { $tmp = lx_tmp_file("/tmp", "xen_ram"); lxfile_mv($statefile, $tmp); $this->umountThis(); $this->restoreXen($tmp); lunlink($tmp); } else { $this->start(); } */ }
function do_restore($docd) { global $gbl, $sgbl, $login, $ghtml; $dbadmin = $this->main->__var_dbadmin; $dbpass = $this->main->__var_dbpassword; $vd = tempnam("/tmp", "mysqldump"); lunlink($vd); mkdir($vd); $docf = "{$vd}/mysql-{$this->main->dbname}.dump"; $ret = lxshell_unzip_with_throw($vd, $docd); if (!lxfile_exists($docf)) { throw new lxException('could_not_find_matching_dumpfile_for_db', '', ''); } $cont = lfile_get_contents($docf); if ($this->main->dbpassword) { $ret = lxshell_input($cont, "__path_mysqlclient_path", "-u", $this->main->username, "-p{$this->main->dbpassword}", $this->main->dbname); } else { $ret = lxshell_input($cont, "__path_mysqlclient_path", "-u", $this->main->username, $this->main->dbname); } if ($ret) { log_restore("Mysql restore failed.... Copying the mysqldump file {$docf} to {$sgbl->__path_kloxo_httpd_root}..."); lxfile_cp($docf, "__path_kloxo_httpd_root"); throw new lxException('mysql_error_could_not_restore_data', '', ''); } lunlink($docf); lxfile_tmp_rm_rec($vd); }