manix Posted August 6, 2011 Share Posted August 6, 2011 I just spent the past half hour searching a decent tutorial on how to AUTOMATICALLY backup mysql database into a file and all I found were some php scripts or mysqldump commands which I have to enter manually.. I am starting to hate how everything I search I don't find and I end up spamming here but I really don't have any other options I guess.. Long story short, how can I have my mysql database backup itself (I guess a mysql event) every 24 hours? Quote Link to comment https://forums.phpfreaks.com/topic/244067-backup/ Share on other sites More sharing options...
phpSensei Posted August 6, 2011 Share Posted August 6, 2011 Hi there, Have you tried the following? <?php include 'config.php'; include 'opendb.php'; $tableName = 'mypet'; $backupFile = 'backup/mypet.sql'; $query = "SELECT * INTO OUTFILE '$backupFile' FROM $tableName"; $result = mysql_query($query); include 'closedb.php'; ?> Quote Link to comment https://forums.phpfreaks.com/topic/244067-backup/#findComment-1253433 Share on other sites More sharing options...
manix Posted August 6, 2011 Author Share Posted August 6, 2011 exactly but I need this to be ran every X hours without me having to do anything Quote Link to comment https://forums.phpfreaks.com/topic/244067-backup/#findComment-1253434 Share on other sites More sharing options...
phpSensei Posted August 6, 2011 Share Posted August 6, 2011 Hi, Then you need to look at Cron Jobs, which sends commands to the server at a predetermined time or intervals of time to run a certain script on you site. http://www.thefactory.ro/php-cron-tutorial Quote Link to comment https://forums.phpfreaks.com/topic/244067-backup/#findComment-1253437 Share on other sites More sharing options...
manix Posted August 6, 2011 Author Share Posted August 6, 2011 Cron is a program installed on Unix / Linux based servers Unfortunately for me my webhost is running in windows (didn't see that coming lol...) and I can't really use this I guess Quote Link to comment https://forums.phpfreaks.com/topic/244067-backup/#findComment-1253444 Share on other sites More sharing options...
phpSensei Posted August 6, 2011 Share Posted August 6, 2011 Hi Manix, I understand your confusion here, the method has derived from linux and implemented to many shared hosting sites nowadays, you can even doing it under windows. If you have cPanel it should be available to you! http://www.siteground.com/tutorials/cpanel/cron_jobs.htm Quote Link to comment https://forums.phpfreaks.com/topic/244067-backup/#findComment-1253447 Share on other sites More sharing options...
manix Posted August 6, 2011 Author Share Posted August 6, 2011 actually there's not such an option in my cpanel but anyways I now know how it's done and for further help I shall address my provider, thank you phpSensei (nice nickname too!) Quote Link to comment https://forums.phpfreaks.com/topic/244067-backup/#findComment-1253452 Share on other sites More sharing options...
phpSensei Posted August 6, 2011 Share Posted August 6, 2011 No problem my friend I am very glad to help you Quote Link to comment https://forums.phpfreaks.com/topic/244067-backup/#findComment-1253456 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.