示例#1
0
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);
}
示例#2
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}";
}
示例#3
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);
 }