Paste this below function in you controller access it via url
http://examplesite.com/controller_name/db_backup
That's all it will do all the rest of work..
function db_backup(){
date_default_timezone_set('Asia/Calcutta');
http://examplesite.com/controller_name/db_backup
That's all it will do all the rest of work..
function db_backup(){
date_default_timezone_set('Asia/Calcutta');
// Load the DB utility class
$this->load->dbutil();
$prefs = array(
'format' => 'zip', // gzip, zip, txt
'filename' => 'backup_'.date('d_m_Y_H_i_s').'.sql',
// File name - NEEDED ONLY WITH ZIP FILES
'add_drop' => TRUE,
// Whether to add DROP TABLE statements to backup file
'add_insert'=> TRUE,
// Whether to add INSERT data to backup file
// Whether to add DROP TABLE statements to backup file
'add_insert'=> TRUE,
// Whether to add INSERT data to backup file
'newline' => "\n"
// Newline character used in backup file
// Newline character used in backup file
);
// Backup your entire database and assign it to a variable
$backup =& $this->dbutil->backup($prefs);
// Load the file helper and write the file to your server
$this->load->helper('file');
write_file('/path/to/'.'dbbackup_'.date('d_m_Y_H_i_s').'.zip', $backup);
// Load the download helper and send the file to your desktop
$this->load->helper('download');
force_download('dbbackup_'.date('d_m_Y_H_i_s').'.zip', $backup);
}
Thank's Sir
ReplyDelete