[Sussex] MySQL replication

Alan F alan at slug.greenmeads.co.uk
Sat Dec 4 00:16:07 UTC 2004


On Fri, Dec 03, 2004 at 04:14:34PM +0000, matthew Macdonald-Wallace wrote:
> All,
> 
> I've got a database that I keep on my laptop that I'd like to be able to
> sync to my desktop every now and then.
> 
> I'm after a way to basically sync the mysql databases between hosts,
> however as it is not a permanent connection (the database has a lot of
> GPS locations on it and the laptop collects more waypoints as I
> drive around), setting them up as a master and a slave seems excessive.
> 
> Is there a way of syncing them over ssh or telnet?
>
I remember looking into doing MySQL replication the proper way.. But I
just got bored and did this hack, since it wasn't for anything
important.

The following as a cgi script on the web server with the database you
want to replicate.

#!/bin/sh
echo -e "Content-type: text/plain\n"
if [ $QUERY_STRING == 'pass=passhere' ]; then
  /usr/bin/mysqldump <loginoptions> database
fi

Then on the "slave" server a script to do something like this (off the
top of my head):

mysqladmin <loginoptions> drop database
mysqladmin <loginoptions> create database
lynx -dump https://host/cgi-bin/dbdump.cgi?pass=passhere | mysql <loginoptions> database

Hope this helps,
Alan




More information about the Sussex mailing list