CodeIgniter Forums
do restore from database backup - 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: do restore from database backup (/thread-25558.html)



do restore from database backup - El Forum - 12-16-2009

[eluser]Lic. Roberto Estupiñán Pérez[/eluser]
I need to restore a mysql database, which previously I did a backup with the function $ this-> dbutil-> backup ();

thks.

Roberto
CU.


do restore from database backup - El Forum - 12-16-2009

[eluser]Ben Edmunds[/eluser]
You can restore it from CLI with


mysql -u username -p databasename < sqlfile.sql


do restore from database backup - El Forum - 12-16-2009

[eluser]Developer13[/eluser]
Or if you have access to phpMyAdmin, you can use the Import function to import the sql file. Will do the same thing as the command line solution Ben posted in case you don't have access to the command line.


do restore from database backup - El Forum - 12-21-2009

[eluser]geshan[/eluser]
but how do I restore it form the front end, web application end. If the user wants to go to a earlier point a CLI or phpmyadmin access will not work. How can I give access via the web application end???


do restore from database backup - El Forum - 12-22-2009

[eluser]flaky[/eluser]
You could write a function, which takes the file ( the *.sql file ) and executes it.

The file uploading part do it in the controller, read the content and send it to the model,
then in the model do this

Code:
$query_list = explode(";", $file_content);

foreach($query_list as $query)
     $this->db->query($query);



do restore from database backup - El Forum - 12-22-2009

[eluser]geshan[/eluser]
That is a way to do it but it will drop all the tables and recreate it. If we could have a robust way like http://drupal.org/project/backup_migrate - Drupal's backup and migrate module which just puts data it'd be great. I'll research on it more. thanks for the help.


do restore from database backup - El Forum - 12-23-2009

[eluser]flaky[/eluser]
So basically what you want, is to be able choose what you want to backup (structure only, data only, structure and data), then based on the backup do the restore.