title: MySQL db sync across locations
body: <p>I have a web app which stores data using MySQL.
  The web app is internal (not available via the internet).</p>
  
  <p>I now have to deploy this application across 3 (and possibly more) locations (branch offices).
  They need to be able to sync the data (entries created at one location be available at the other branch locations).</p>
  
  <p>Requirements</p>
  
  <ul>
  <li>local instances of web app + mysql database</li>
  <li>each location reads and writes locally / is on own network</li>
  <li>database is synced one per day (possibly through a script via SSH) so that each location has the same data.</li>
  </ul>
  
  <p>The only way that I was able to figure this out (so far) is to create UUID (unique identifiers) and to encode each row with a source bit (for originating location) and sync bit (new=0, synced=1) then to write a script where I SSH to each location nightly and add rows that = my source and synced=0 to each location... I realize this is brute and not very elegant/reliable but I am not sure what else to do.</p>
  
  <p>The client is afraid that if internet connection fails he wants to be able for the app to function locally, but still have a sync between other branches (via a nightly script or otherwise). As I said, there are already a total of 3 locations and possibly more coming in later this year.</p>
  
  <p>Any advice on architecture would be appreciated.</p>
  
  <p>PS. I am not connecting the database to internet because of security concerns. But am open to all suggestions.</p>
  
  <p>Thanks.</p>