Welcome Guest, Not a member yet? Register   Sign In
Export backup database in gzip file format


I'm reading http://ellislab.com/codeigniter/user-gui...tml#backup for backup my database.

Now, I have this script:

        $repertoire_sauvegardes = 'saves_database/' ;
        $prefs = array(
                'tables'      => array(),  // Array of tables to backup.
                'ignore'      => array('vado_log'),           // List of tables to omit from the backup
                'format'      => 'txt',             // gzip, zip, txt
                'filename'    => $this->db->database.'_backup_'.date('Y-m-d_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
                'newline'     => "\n"               // Newline character used in backup file

        $content = $this->dbutil->backup($prefs);
        if( is_dir ($repertoire_sauvegardes) === FALSE ) {

            if(mkdir ($repertoire_sauvegardes, 0700) === FALSE ) {
                exit('Impossible de créer le répertoire pour la sauvegarde de la mysql');
        file_put_contents($repertoire_sauvegardes.$prefs['filename'], $content);

But I want use gzip file format, not txt format for the write are more speedly.

How I can do this ?

Thanks for your help.

'format'      => 'gzip',             // gzip, zip, txt

Make sure that you turn on gzip in php.ini and ./application/config/config.php

$config['compress_output'] = TRUE;


But when I config to TRUE, my website don't works.

Quote:Page Web inaccessible
Il se peut que la page Web à l'adresse http://localhost:8080/Vadorequest.fr/ soit temporairement inaccessible ou qu'elle ait été déplacée de façon permanente à une autre adresse Web.
Erreur 330 (net::ERR_CONTENT_DECODING_FAILED) : Erreur inconnue

For the moment I'm using txt format, it's works perfectly and it's very speedly.
Use gzip will be really better or it's not very useful ?

[eluser]Rowan Wilson[/eluser]
Depends how big your tables are, how many backups you plan to store and also if you plan to download the backups.

It comes down to what you need and what your server can accomodate: smaller file sizes or extra CPU cycles to create the zipped file.

FYI: Your code works for me just by setting the format to gzip and without setting:

$config['compress_output'] = TRUE;

I use a mutualised OVH server so...

Thanks for your help, for the moment I don't need gzip file so I will try without for the moment.

Good evening.

Theme © iAndrew 2016 - Forum software by © MyBB