Portal Home > Knowledgebase > Articles Database > Cron Job, coding a .php file to do something


Cron Job, coding a .php file to do something




Posted by iPhonic, 01-03-2011, 06:27 PM
Hello, Basically, I want to have a .php file which stores a command which does the following: Restore a MySQL database with a backup SQL every so often. How would I code this into a .php file so that a cronjob can run it every week or so? Thank you.

Posted by zoticaic, 01-03-2011, 06:30 PM
Is there any certain reason you need to do this on PHP if it will be a cronjob anyway? How about a shell script? Take note of the steps on when you restore manually and then use them on the shell script, it should get you started

Posted by iPhonic, 01-03-2011, 06:33 PM
Hello there, thank you for the reply. If this can be accomplished via the cron job command tool, then great, but I just don't know how I should do it. I am not good with programming nor do I have any experience.

Posted by zoticaic, 01-03-2011, 06:37 PM
Automated restores can vary depending on how you created your backup and what you want to restore. Tell us here so we can give you ideas or better yet seek professional help if you are concerned with your data

Posted by iPhonic, 01-04-2011, 07:03 AM
So I have a few MySQL databases, each with their own SQL back ups which I have downloaded. I want a cron job which will restore each of those MySQL databases with the backps I have (which will be uploaded) every week.

Posted by iPhonic, 01-04-2011, 01:22 PM
Hoping some can help ASAP .

Posted by Evilzebra, 01-04-2011, 02:25 PM
Are your backups simply .sql with all of the data dumped into it? If so you can probably use this. LOAD DATA INFILE 'backup.sql' INTO TABLE db2.my_table; I can't link the documentation because I am new here. But if you google "INFILE" I'm sure you'll find it.



Was this answer helpful?

Add to Favourites Add to Favourites    Print this Article Print this Article

Also Read
Shopping Cart Help (Views: 582)
New system setup (Views: 629)