PostgreSQL – Odoo Databases Synchronization

postgresql

I have to deploy odoo with postgres database on amazon cloud. That i can do by simply setting up EC2 server and setting uo odoo on it. In case if internet in down, I want to be able to access same services and already saved data offline as well. For that I plan to install odoo with postgres database on my local machine (in my office) as well. Now I can access odoo services from anywhere (using cloud) when there is internet available. But in case if internet is down, I must be able to use locally installed odoo to get same services. For that purpose I need two things

Both databases should be exact replicas of each other.
On recovering from internet disconnectivity, I want the changes made in my local ( office) database reflect in the database at amazon cloud.
I am new to this stuff, kindly suggest the best possible approach (architecture) in this scenario.

Best Answer

I'm currently evaluating a similar setup and there are a couple of solutions.

What you're looking at here is basically a master-master replication scenario, where both databases are writable and changes in each are replicated to the other.

There is Bucardo, which is a postgresql-only replication system written in Perl and there are a number of tutorials for setting it up, check the Odoo community forums, too.

Then there's SymmetricDS, which does the same for a number of different databases and is written in Java.

Since your're dealing with master-master replication, you have to account for the occasion of both databases changing the same rows in the same table at the same time, so you'll have to configure conflict-resolution strategies (basically which change wins, but it can be a lot more involved like calling an external handler to figure out what to do).