Translate

Thursday, October 4, 2012

Sync data between multiple database

Option one is to enable binary logs on each laptop and then replay these on the master database when reconnected. You can use 

mysqlbinlog logfile > mysql --host=masterdbserver 

This should be straightforward. It will apply all changes from the offline laptops to the master. 

Option two is to sync only changed and inserted records from the laptops to the master with MySQL Table Sync (http://sourceforge.net/projects/mysqltoolkit). Use the --onlydo option for this. 

Then you have to get the changes back from the central database to the laptops. If you are using MyISAM tables, rsync might be the best option; otherwise you can use MySQL Table Sync again.