Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sync large local DB with server DB (MySQL)

I need to weekly sync a large (3GB+ / 40+ tables) local MySQL database to a server database. The two databases are exactly the same. The local DB is constantly updated and every week or so the server DB need to be updated with the local data. You can call it 'mirrored DB' or 'master/master' but I'm not sure if this is correct.

Right now the DB only exist locally. So:

1) First I need to copy the DB from local to server. With PHPMyAdmin export/import is impossible because of the DB size and PHPMyAdmin limits. Exporting the DB to a gzipped file and uploading it through FTP probably will break in the middle of the transfer because of connection to the server problems or because of the server file size limit. Exporting each table separately will be a pain and the size of each table will also be very big. So, what is the better solution for this?

2) After the local DB us fully uploaded to the server I need to weekly update the server DB. What the better way to doing it?

I never worked with this kind of scenario, I don't know the different ways for achieving this and I'm not precisely strong with SQL so please explain yourself as good as possible.

Thank you very much.

like image 921
Jonathan Avatar asked Oct 14 '10 08:10

Jonathan


1 Answers

This article should get you started.

Basically, get Maatkit and use the sync tools in there to perform a master-master-synchronization:

 mk-table-sync --synctomaster h=serverName,D=databaseName,t=tableName
like image 59
Aaron Digulla Avatar answered Oct 02 '22 06:10

Aaron Digulla