CodeIgniter Forums
Export backup database in gzip file format - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forum-23.html)
+--- Thread: Export backup database in gzip file format (/thread-56563.html)



Export backup database in gzip file format - El Forum - 01-02-2013

[eluser]Vadorequest[/eluser]
Hi,

I'm reading http://ellislab.com/codeigniter/user-guide/database/utilities.html#backup for backup my database.

Now, I have this script:

Code:
$this->load->dbutil();
        $this->load->helper('file');
        
        $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.


Export backup database in gzip file format - El Forum - 01-02-2013

[eluser]InsiteFX[/eluser]
Code:
'format'      => 'gzip',             // gzip, zip, txt

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

Code:
$config['compress_output'] = TRUE;



Export backup database in gzip file format - El Forum - 01-02-2013

[eluser]Vadorequest[/eluser]
Thanks.

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 ?


Export backup database in gzip file format - El Forum - 01-02-2013

[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:

Code:
$config['compress_output'] = TRUE;



Export backup database in gzip file format - El Forum - 01-02-2013

[eluser]Vadorequest[/eluser]
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.