<?php

if (!defined('BASEPATH')) {
    exit('No direct script access allowed');
}

/**
 * Description of backup
 *
 * @author Igor Ratsun
 */
class Backup extends \Ciext\Controller\AbstractAdminController
{

    public function backup_db()
    {
        // Access check
        if (!$this->rt_user->isAllowed('system', 'backup_db')) {
            show_404('', FALSE);
        }

        // Load the DB utility class
        $this->load->dbutil();

        // Backup your entire database and assign it to a variable
        $backup = $this->dbutil->backup();

        // Load the download helper and send the file to your desktop
        $this->load->helper('download');
        force_download(date('Y_m_d_H_i_') . $this->db->database . '.sql.gz', $backup);
    }

}

