Mysql – How to regularly export from one database to another (on same server) in a daily fashion

apache-2.2MySQLPHP

Running a beta site (different platform than live site).

Already have export / import process via php script. Automatically gets data from one database and exports to another.

I want to automatically run this (at least daily) transfer to update the beta site with content from live site.

What's my simplest option (aside from manually running the script)?

I was considering:

  1. Writing additional functionality into the script to track when last run or run based on a set server timestamp

  2. Writing additional functionality to check database for new / updated data (no idea if this is possible)

  3. ?????

Also, perhaps this is better suited for a different site (not serverfault), let me know.

Best Answer

You should be able to accomplish this with a simple cronjob that does a sqldump from the first, then sqlimport and restart the second SQL instance (if necessary...)

Personally, I like adding 'logger' statements to my cronjobs to note a step that's beginning and another when it ends so that I can track how long things take.