Thread: Synch to Database with same schema.

Synch to Database with same schema.

From
roody senecal
Date:
Hello
We have a custom app running at two locations, where DB is at Location A and location B connects to it via a VPN. Our internet went down (long story) at location A. As a temporary solution I install the DB at Location B, so now location A and B are on different DB. After about four weeks internet is back online. How can I synch and compare the two databases and make them the same, so I can go back to the original setup. (I need a tool that can compare the two db and add all the entries that are in B, but not in A to A)


Rudy


Re: Synch to Database with same schema.

From
Frank Bax
Date:
roody senecal wrote:
> Hello
> We have a custom app running at two locations, where DB is at Location A
> and location B connects to it via a VPN. Our internet went down (long
> story) at location A. As a temporary solution I install the DB at
> Location B, so now location A and B are on different DB. After about
> four weeks internet is back online. How can I synch and compare the two
> databases and make them the same, so I can go back to the original
> setup. (I need a tool that can compare the two db and add all the
> entries that are in B, but not in A to A)


pg_dump DatabaseA > BackupA
pg_dump DatabaseB > BackupB
diff BackupA BackupB > Changes

If conditions are exactly as you think they are; then "Changes" should
only contain INSERT statements which are in BackupB, but not in BackupA.
  Use psql to execute the INSERT statements.

If "Changes" file indicates that some rows were changed instead of
inserted; then you can still contruct an approriate "UPDATE" from the
output of diff.