1. Simple Expression Engine Database Backup

    Posted by Vinay on July 01, 2011 in Expression Engine

    A simple Expression Engine database backup solution using php in templates and Codeigniter database Utilities.

    All you have to do is create a EE template and enable php. Add the following code and viola, visit the url in your browser and download the full database backup.

    <?php

    $this
    ->EE =& get_instance();
    // Load the DB utility class
    $this->EE->load->dbutil();

    // Backup your entire database and assign it to a variable
    $backup =& $this->EE->dbutil->backup();

    // Load the file helper and write the file to your server
    $this->EE->load->helper('file');
    write_file('SERVER_PATH/mybackup.gz'$backup);

    // Load the download helper and send the file to your desktop
    $this->EE->load->helper('download');
    force_download('mybackup.gz'$backup); 

    ?> 

    You can customize the filename, tables etc. Follow this guide : http://codeigniter.com/user_guide/database/utilities.html#backup

    Do remember to password protect the template to prevent unauthorized access.

    Good luck