Ejemplo n.º 1
0
    $outputdir = $conf->admin->dir_output . '/backup';
    $outputfile = $outputdir . '/' . $file;
    $outputfiletemp = $outputfile . '-TMP.sql';
    // for compression format, we add extension
    $compression = GETPOST('compression') ? GETPOST('compression', 'alpha') : 'none';
    if ($compression == 'gz') {
        $outputfile .= '.gz';
    }
    if ($compression == 'bz') {
        $outputfile .= '.bz2';
    }
    $outputerror = $outputfile . '.err';
    dol_mkdir($conf->admin->dir_output . '/backup');
    if ($compression == 'gz' or $compression == 'bz') {
        backup_tables($outputfiletemp);
        dol_compress_file($outputfiletemp, $outputfile, $compression);
        unlink($outputfiletemp);
    } else {
        backup_tables($outputfile);
    }
    $_SESSION["commandbackuplastdone"] = "";
    $_SESSION["commandbackuptorun"] = "";
}
// POSTGRESQL
if ($what == 'postgresql') {
    $cmddump = GETPOST("postgresqldump");
    // Do not sanitize here with 'alpha', will be sanitize later by escapeshellarg
    if ($cmddump) {
        dolibarr_set_const($db, 'SYSTEMTOOLS_POSTGRESQLDUMP', $cmddump, 'chaine', 0, '', $conf->entity);
    }
    $outputdir = $conf->admin->dir_output . '/backup';
Ejemplo n.º 2
0
    /**
     * testDolCompressUnCompress
     *
     * @return	string
     */
    public function testDolCompressUnCompress()
    {
        global $conf,$user,$langs,$db;
        $conf=$this->savconf;
        $user=$this->savuser;
        $langs=$this->savlangs;
        $db=$this->savdb;

        $format='zip';
        $filein=dirname(__FILE__).'/Example_import_company_1.csv';
        $fileout=$conf->admin->dir_temp.'/test.'.$format;
        $dirout=$conf->admin->dir_temp.'/test';

        dol_delete_file($fileout);
        $count=0;
        dol_delete_dir_recursive($dirout,$count,1);

        $result=dol_compress_file($filein, $fileout, $format);
        print __METHOD__." result=".$result."\n";
        $this->assertGreaterThanOrEqual(1,$result);

        $result=dol_uncompress($fileout, $dirout);
        print __METHOD__." result=".join(',',$result)."\n";
        $this->assertEquals(0,count($result));
    }