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:
The problem is that you are trying to backup the database very early during bootstrapping.
I ran into the same problem when I tried to hack CodeIgniter into backing up my database using:
$prefs = array(
'ignore'=> array('codes_cdt','codes_cpt','codes_icd10_dx_order','codes_icd10_pcs_order','pharma'),
'format'=>'gzip','filename','add_drop'=> TRUE,'add_insert'=>TRUE,'newline'=> "\n");
$filename = APPPATH.'\\backups\\' .'backup-' . date('d-m-Y') . ' .gz';
if(!file_exists($filename)){
get_instance()->load->dbutil();
file_put_contents( $filename, $this->dbutil->backup($prefs));
}
at the bottom of my config.php file.
Move this to a model an allow it to autoload, and you will be fine.