mtgriffiths Posted April 19, 2008 Share Posted April 19, 2008 Hi Guys, What im looking to do is back a table from my database up upon the click of a button. I have not done anything like this before so i am finding this difficult. Can any one help? Thanks Matthew Link to comment https://forums.phpfreaks.com/topic/101869-backup/ Share on other sites More sharing options...
Fadion Posted April 19, 2008 Share Posted April 19, 2008 Never tried this, but i think it'll work: <?php $file = 'backup' . date("m-d-y") . '.sql'; //set also the date in the filename $resultsBackup = mysql_query("SELECT * INTO OUTFILE '$file' FROM yourtable"); ?> To restore it: <?php $file = 'backup04-19-08.sql'; $resultsRestore = mysql_query("LOAD DATA INFILE '$file' INTO TABLE yourtable"); ?> Link to comment https://forums.phpfreaks.com/topic/101869-backup/#findComment-521377 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.