Vinay M

#02-06 Silahis Apartments
121 Lorong K Telok Kurau
Singapore - 425762

Please send us a message and
we will get back to you within 1-2 working days.

Simple Expression Engine Database Backup

Posted by on 01 July 2011 in Read Later

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 modify the "SERVER_PATH" variable 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