Beispiel #1
0
 public function do_backup()
 {
     global $gbl, $sgbl, $login, $ghtml;
     $tmpbasedir = $this->main->__var_tmp_base_dir;
     if ($this->isLVM()) {
         //$file = $this->saveXen();
         if ($this->main->isOn('__var_bc_backupextra_stopvpsflag')) {
             $this->stop();
         }
         try {
             $mountpoint = $this->takeSnapshot();
         } catch (Exception $e) {
             //$this->restoreXen($file);
             $this->start();
             throw $e;
         }
         if ($this->main->isOn('__var_bc_backupextra_stopvpsflag')) {
             $this->start();
         }
         $this->main->__snapshotmount = $mountpoint;
         $this->main->__save_variable['__snapshotmount'] = $mountpoint;
     } else {
         $this->stop();
         $mountpoint = $this->mount_this_guy();
     }
     if (!$this->main->isWindows()) {
         $mountpoint = expand_real_root($mountpoint);
         $list = lscandir_without_dot($mountpoint);
         $list = array_remove($list, "proc");
         if (count($list) < 6) {
             throw new lxException("not_enough_directories_in_vps_root,_possibly_wrong_location", '', '');
         }
     } else {
         $tmpdir = createTempDir($tmpbasedir, "lx_{$this->main->nname}_backup");
         $vgname = fix_vgname($this->main->corerootdir);
         $snapshot = "/dev/{$vgname}/{$this->main->nname}_snapshot";
         $partition = get_partition($snapshot, $this->main->corerootdir);
         lxshell_return("ntfsfix", $partition);
         $ret = lxshell_return("ntfsclone", "--force", "--save-image", "-O", "{$tmpdir}/backup.img", $partition);
         if ($ret) {
             kpart_remove("/dev/mapper/{$vgname}-{$this->main->nname}_snapshot");
             lvm_remove($snapshot);
             throw new lxException("could_not_clone");
         }
         kpart_remove("/dev/mapper/{$vgname}-{$this->main->nname}_snapshot");
         $list = array("backup.img");
         $mountpoint = $tmpdir;
         $this->main->__windows_tmpdir = $tmpdir;
         lvm_remove($snapshot);
     }
     return array($mountpoint, $list);
 }
Beispiel #2
0
function lxfile_get_ntfs_disk_usage($file, $root)
{
    $file = expand_real_root($file);
    $root = fix_vgname($root);
    $ldevice = get_partition($file, $root);
    $res = lxshell_output("ntfscluster", "-f", $ldevice);
    $base = basename($file);
    kpart_remove("/dev/mapper/{$root}-{$base}");
    $res = explode("\n", $res);
    foreach ($res as $r) {
        $r = trim($r);
        if (!csa($r, ":")) {
            continue;
        }
        list($var, $val) = explode(":", $r);
        $var = trim($var);
        $val = trim($val);
        if ($var === "bytes per volume") {
            $total = round($val / (1024 * 1024), 1);
        }
        if ($var === "bytes of user data") {
            $used = round($val / (1024 * 1024), 1);
        }
    }
    $ret['total'] = $total;
    $ret['used'] = $used;
    return $ret;
}