PDA

View Full Version : Need Help With Cron Job to Restore MySQL Database Every Hour



jezze
09-08-2011, 09:25 PM
Hello,
I need to restore a MySQL database every hour for a demo site.
Basically I need to restore the database to get rid of spam and changes made to the database.

I would appreciate if someone can show me the syntax for a cron job to restore my database every hour

Thanks
Jesse

siguie
09-09-2011, 03:45 AM
Assuming the file you restore is called "file.sql" then the shell command is ...

mysql -u USERNAME -p PASSWORD DATABASENAME < file.sql

Just replace the capitalized bits with your info ... and you will need the absolute path to 'file.sql'


There is probably some upper size limit for the MySQL file too but I've gotten to work for 10mb files.

jezze
09-09-2011, 01:53 PM
Hello Siguie,

How can I find out the absolute path where my database is located?
Where I should upload my database, where is the best location?

Thanks for your help
Jezze