CodeIgniter Forums

Full Version: Out of memory for backup
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

El Forum

Hi there,
I got a problem regarding backup. It used to be fine... Last time I used was about a week ago.
Here is the script I use :
class BackupDatabase extends Controller {

    function __construct()
    function index()
        $now = date("d-m-Y H:i:s");
        $prefs = array(
            'format'      => 'gz',
            'filename'    => 'backup '.$now.'.sql',
            'add_drop'    => TRUE,              
            'add_insert'  => TRUE,        
            'newline'     => "\n"
        $backup =& $this->dbutil->backup();

        force_download('backup '.$now.'.gz', $backup);        

I got this error message :
Fatal error: Out of memory (allocated 24903680) (tried to allocate 18361504 bytes) in ../system/database/DB_utility.php on line 347

I wonder what is happening ? If about php.ini... I'm afraid I don't access for that.
I also tried ini_set(), didn't work.
I use patched CI 1.7.2, and I don't think the patch got anything to do with download process.

Can someone help me ? Sorry for the broken english. Thank you in advance.

PS : Uhh, I just realized, I posted in the wrong section. I'm sorry, can anyone move this to the correct one ?

El Forum

The backup method of the database driver creates the output file in memory. Not very useful if you have more than a few records in your tables.

The utility classes desparately need to be rewritten to use disk storage for generating the backup files, so you're not size limited.

El Forum

Whew.... good to go again. X_X
Thanks for the help.

Eee... one more thing, why I cannot write file output in this way ?
$now = date("d-m-Y H:i:s");
$backup = 'asdfgsdgfasfgvasgf';
write_file('./backup/filebackup'.$now.'.txt', $backup);
About the date part, whenever I'm trying to write the file with date added to file name, it won't produce file output.
But if I'm not using it, it can. Is there a way so I can write a file with date added to file name ?

$backup = 'asdfgsdgfasfgvasgf';
write_file('./backup/filebackup.txt', $backup);
This one will produce output.

Is it impossible since the file name will consist of "-" and ":" ?