Matthew Hutchinson

about

Matt is a web developer from N. Ireland. He currently runs Hiddenloop and works in Dublin. Want to find out just a little bit more ?

An audio feed is available for the latest articles at matthewhutchinson.net, find it here.

Auto-syncing your local database from a remote MySQL Server (Dreamhost)

posted on Monday, the 24th of April 2006 at 09:13 in , ,

While redesigning this blog (which I still havent finished), I thought it would be a good idea to setup an automatic synch; from my Live Typo database at Dreamhost – through to my local Windows machine. Setup as a daily cron, I now have all my Typo data fed through to my windows machine, including all the posts, and settings I add and change here on the live site.

My local Typo install runs on Apache with FastCGi and MySQL. The cronjob on dreamhost runs daily at 9pm (when im sure that my local machine is turned on) – and simply calls this mysqldump command.

mysqldump --add-drop-table remotedatabasename -h remotehostname -u
remoteusername -premotepassword | mysql -u localusername -plocalpassword
-h localhostname.no-ip.org localdatabasename

In order for this command to work, you’ll also have to setup the following;

  • Your local MySQL server must be configured to allow incoming connections from remote machines.
  • The MySQL user on your local server to access the database, should be configured to allow login from a remote connection, or a specific IP (e.g. your Dreamhosts box, IP address or hostname)
  • If you use a hardware firewall/router on your local machine, it must be configured to port forward on MySQL (usually port 3306) – to your local machine that has MySQL running.
  • Unless your firewall or local machine has been issued with a static IP, your going to need to use a service like No-ip.com - that gives your local router or PC a hostname you can always reference - and that is automatically updated when changed. After registering, No-ip.com offer this as a free service.
Liquid error: Expected /u/apps/matthewhutchinson.net/current/config/../app/models/tagging.rb to define Tagging