I have been looking into the user guide which came with CodeIgniter. I became very interested with the dbutil()
method. Particularly the following line of code:
function backup($fileName='db_backup.zip'){
// Load the DB utility class
$this->load->dbutil();
// Backup your entire database and assign it to a variable
$backup =& $this->dbutil->backup();
// Load the file helper and write the file to your server
$this->load->helper('file');
write_file(FCPATH.'/downloads/'.$fileName, $backup);
// Load the download helper and send the file to your desktop
$this->load->helper('download');
force_download($fileName, $backup);
}
Easy way to backup database using codeigniter