Exemple #1
0
function do_zip_to_fileserv($type, $arg)
{
    lxfile_mkdir("__path_serverfile/tmp");
    lxfile_unix_chown_rec("__path_serverfile", "lxlabs");
    $basebase = basename($arg[0]);
    $base = basename(ltempnam("__path_serverfile/tmp", $basebase));
    // Create the pass file now itself so that it isn't unwittingly created again.
    if ($type === 'zip') {
        $vd = $arg[0];
        $list = $arg[1];
        dprint("zipping {$vd}: " . implode(" ", $list) . " \n");
        $ret = lxshell_zip($vd, "__path_serverfile/tmp/{$base}.tmp", $list);
        lrename("__path_serverfile/tmp/{$base}.tmp", "__path_serverfile/tmp/{$base}");
    } else {
        if ($type === 'tgz') {
            $vd = $arg[0];
            $list = $arg[1];
            dprint("tarring {$vd}: " . implode(" ", $list) . " \n");
            $ret = lxshell_tgz($vd, "__path_serverfile/tmp/{$base}.tmp", $list);
            lrename("__path_serverfile/tmp/{$base}.tmp", "__path_serverfile/tmp/{$base}");
        } else {
            if ($type === 'tar') {
                $vd = $arg[0];
                $list = $arg[1];
                dprint("tarring {$vd}: " . implode(" ", $list) . " \n");
                $ret = lxshell_tar($vd, "__path_serverfile/tmp/{$base}.tmp", $list);
                lrename("__path_serverfile/tmp/{$base}.tmp", "__path_serverfile/tmp/{$base}");
            }
        }
    }
    if ($ret) {
        throw new lxException("could_not_zip_dir", '', $vd);
    }
    return "__path_serverfile/tmp/{$base}";
}
Exemple #2
0
 function top_level_simple_backup()
 {
     global $gbl, $sgbl, $login, $ghtml;
     $progname = $sgbl->__var_program_name;
     $dir = dirname($this->main->__var_bc_filename);
     $name = basename($this->main->__var_bc_filename);
     $firstname = strtil($name, "-");
     lxfile_mkdir($dir);
     $list = lscandir_without_dot($dir);
     $bc = $this->do_backup();
     $tmpdir = createTempDir("{$sgbl->__path_tmp}", "backupfile");
     lfile_put_contents("{$tmpdir}/{$progname}.file", $this->main->__var_bc_metafile);
     lfile_put_contents("{$tmpdir}/{$progname}.metadata", $this->main->__var_bc_metadata);
     $newarray = lx_array_merge(array($bc[1], array("{$tmpdir}/{$progname}.file", "{$tmpdir}/{$progname}.metadata")));
     if ($this->main->getZiptype() === 'zip') {
         lxshell_zip($bc[0], $this->main->__var_bc_filename, $newarray);
     } else {
         if ($this->main->getZiptype() === 'tar') {
             lxshell_tar($bc[0], $this->main->__var_bc_filename, $newarray);
         } else {
             lxshell_tgz($bc[0], $this->main->__var_bc_filename, $newarray);
         }
     }
     print_time("cpzip", "Copy and Zip");
     lxfile_tmp_rm_rec("{$tmpdir}");
     $this->do_backup_cleanup($bc);
 }