Backups\Controller\Backups::create PHP Method

create() public method

public create ( )
    public function create()
    {
        set_time_limit(0);
        $timestamp = time();
        $target = $this->param('target', 'site');
        $filename = "{$timestamp}.{$target}.zip";
        $rootfolder = $this->app->path($target == 'cockpit' ? "#root:" : "site:");
        $this->app->helper("backup")->backup($rootfolder, $this->app->path("#backups:") . "/{$filename}", function ($file) {
            return preg_match('/cache/', $file) && !preg_match('/index\\.html/', $file) || preg_match('/backups/', $file) && !preg_match('/index\\.html/', $file);
        });
        return json_encode(["timestamp" => $timestamp, "info" => $target, "file" => "{$timestamp}.{$target}", "size" => $this->app->helper("utils")->formatSize(filesize($this->app->path("#backups:{$filename}")))]);
    }