src/Controllers/DeployController.php
private function backupDatabase()
    {
        // get the name of the DB to backed up and the connection to use
        $dbdir = database_path();
        $dbconn = config('database.default');
        $dbname = config("database.connections.$dbconn.database");

        // make a directory for the backup file and switch into that directory
        $cmd = new Command('cd');
        $cmd->addParam($dbdir)
            ->addSubCommand('&&')
            ->addSubCommand('mkdir')
            ->addParam('backups');
        if ($this->ex($cmd)) {
            $cmd = new Command('cd');
            $cmd->addParam($dbdir.'/backups')
                ->addSubCommand('&&');
            switch ($dbconn) {
                case 'sqlite':
                    $cmd->addSubCommand('cp');
                    $cmd->addParam($dbname)
                        ->addParam('.');

                    return $this->ex($cmd);
                case 'mysql':
                    $cmd->addSubCommand('mysqldump');
                    $cmd->addParam($dbname)
                        ->addParam('>')
                        ->addParam("$dbname.sql");

                    return $this->ex($cmd);
                case 'pgsql':
                    $cmd->addSubCommand('pg_dump');
                    $cmd->addParam($dbname)
                        ->addParam('>')
                        ->addParam("$dbname.sql");

                    return $this->ex($cmd);
            }
        }

        return false;
    }
private function backupDatabase()
    {
        // get the name of the DB to backed up and the connection to use
        $dbdir = database_path();
        $dbconn = config('database.default');
        $dbname = config("database.connections.$dbconn.database");

        // make a directory for the backup file and switch into that directory
        $cmd = new Command('cd');
        $cmd->addParam($dbdir)
            ->addSubCommand('&&')
            ->addSubCommand('mkdir')
            ->addParam('backups');
        if ($this->ex($cmd)) {
            $cmd = new Command('cd');
            $cmd->addParam($dbdir.'/backups')
                ->addSubCommand('&&');
            switch ($dbconn) {
                case 'sqlite':
                    $cmd->addSubCommand('cp');
                    $cmd->addParam($dbname)
                        ->addParam('.');

                    return $this->ex($cmd);
                case 'mysql':
                    $cmd->addSubCommand('mysqldump');
                    $cmd->addParam($dbname)
                        ->addParam('>')
                        ->addParam("$dbname.sql");

                    return $this->ex($cmd);
                case 'pgsql':
                    $cmd->addSubCommand('pg_dump');
                    $cmd->addParam($dbname)
                        ->addParam('>')
                        ->addParam("$dbname.sql");

                    return $this->ex($cmd);
            }
        }

        return false;
    }
Backup the database.

@return bool True if the database was successfully backed up. False on error.