public function backupAction()
    {
        $filter = $this->getSearchFilter();
        $model = $this->getModel();

        $tables = $model->load();
        $allTables = [];
        $noDataTables = [];
        foreach($tables as $table) {
            if ($table['type'] == 'view' && (!array_key_exists('include_views', $filter) || $filter['include_views'] != '1')) {
                continue;
            }
            $allTables[] = $table['name'];
            if ($table['respondentData'] === true && (!array_key_exists('include_respondent_data', $filter) || $filter['include_respondent_data'] != '1')) {
                $noDataTables[] = $table['name'];
            }
        }

        $filename = $this->getBackupFilename($filter);
        $dbConfig = $this->getDatabaseConfig();
        $dumpSettings = [
            'include-tables' => $allTables,
            'no-data' => $noDataTables,
            'single-transaction' => true,
            'lock-tables' => false,
            'add-locks' => false,
            'add-drop-table' => true,
        ];

        ini_set('max_execution_time', 300);

        try {
            $dump = new \Ifsnop\Mysqldump\Mysqldump($dbConfig['dsn'], $dbConfig['username'], $dbConfig['password'], $dumpSettings);
            $dump->start($filename);
            echo sprintf($this->_('Database backup completed. File can be found in %s'), $filename);
        } catch (\Exception $e) {
            echo 'mysqldump-php error: ' . $e->getMessage();
        }
    }
public function backupAction()
    {
        $filter = $this->getSearchFilter();
        $model = $this->getModel();

        $tables = $model->load();
        $allTables = [];
        $noDataTables = [];
        foreach($tables as $table) {
            if ($table['type'] == 'view' && (!array_key_exists('include_views', $filter) || $filter['include_views'] != '1')) {
                continue;
            }
            $allTables[] = $table['name'];
            if ($table['respondentData'] === true && (!array_key_exists('include_respondent_data', $filter) || $filter['include_respondent_data'] != '1')) {
                $noDataTables[] = $table['name'];
            }
        }

        $filename = $this->getBackupFilename($filter);
        $dbConfig = $this->getDatabaseConfig();
        $dumpSettings = [
            'include-tables' => $allTables,
            'no-data' => $noDataTables,
            'single-transaction' => true,
            'lock-tables' => false,
            'add-locks' => false,
            'add-drop-table' => true,
        ];

        ini_set('max_execution_time', 300);

        try {
            $dump = new \Ifsnop\Mysqldump\Mysqldump($dbConfig['dsn'], $dbConfig['username'], $dbConfig['password'], $dumpSettings);
            $dump->start($filename);
            echo sprintf($this->_('Database backup completed. File can be found in %s'), $filename);
        } catch (\Exception $e) {
            echo 'mysqldump-php error: ' . $e->getMessage();
        }
    }
public function backupAction ( ) { $ filter = $ this -> getSearchFilter ( ) ; $ model = $ this -> getModel ( ) ; $ tables = $ model -> load ( ) ; $ allTables = [ ] ; $ noDataTables = [ ] ; foreach ( $ tables as $ table ) { if ( $ table [ 'type' ] == 'view' && ( ! array_key_exists ( 'include_views' , $ filter ) || $ filter [ 'include_views' ] != '1' ) ) { continue ; } $ allTables [ ] = $ table [ 'name' ] ; if ( $ table [ 'respondentData' ] === true && ( ! array_key_exists ( 'include_respondent_data' , $ filter ) || $ filter [ 'include_respondent_data' ] != '1' ) ) { $ noDataTables [ ] = $ table [ 'name' ] ; } } $ filename = $ this -> getBackupFilename ( $ filter ) ; $ dbConfig = $ this -> getDatabaseConfig ( ) ; $ dumpSettings = [ 'include-tables' => $ allTables , 'no-data' => $ noDataTables , 'single-transaction' => true , 'lock-tables' => false , 'add-locks' => false , 'add-drop-table' => true , ] ; ini_set ( 'max_execution_time' , 300 ) ; try { $ dump = new \ Ifsnop \ Mysqldump \ Mysqldump ( $ dbConfig [ 'dsn' ] , $ dbConfig [ 'username' ] , $ dbConfig [ 'password' ] , $ dumpSettings ) ; $ dump -> start ( $ filename ) ; echo sprintf ( $ this -> _ ( 'Database backup completed. File can be found in %s' ) , $ filename ) ; } catch ( \ Exception $ e ) { echo 'mysqldump-php error: ' . $ e -> getMessage ( ) ; } }
Action for the actual backup of the database
Action for the actual backup of the database