Page 1 of 1

How to backup data in the database?

Posted: Thu Jan 20, 2011 12:39 pm
by nettolan
Hi people!

Just recently got into coding and i'm a total idiot in it. I got no idea how to backup data in the database.

Anyone have any PHP script which i can use to backup data in the database?

After backing up, how do i restore using PHP codes?

Re: How to backup data in the database?

Posted: Thu Jan 20, 2011 2:48 pm
by John Cartwright
There are a million tutorials that can do this.

Basically it comes down to running the following query, which basically just dumps the contents of the table into a file.

SELECT * INTO OUTFILE 'your_backup_file.sql' FROM `your_table_name`

Creating a PHP script to run this, then configure a cron job to run the PHP script at whatever interval.

Then to load it

LOAD DATA INFILE 'your_backup_file.sql' INTO TABLE `your_table_name`

And finally, for my favorite resource which will answer your question in extreme detail - http://lmgtfy.com/?q=PHP+MySQL+backup