A list of PostgreSQL libraries, tools and resources
github.com
github.com
a) I think most people end up doing some kind of batch synchronization, but I'm interested in streaming solutions.
b) A lot of folks use trigger based replication, but triggers have to be on the primary/master node, and not just on the replicas.
c) Another common solution is to force the database client to write to a message broker, but that opens the door to data discrepancies and synchronization issues.
d) In theory I think the best way is to do something like bottledwater-pg or pg_kafka [1] [2] [3], but I'm not sure how battle hardened these are. I think logical replication of the WAL is the right approach, but there is still not much tooling around this.
[1] https://github.com/confluentinc/bottledwater-pg
[2] https://github.com/xstevens/pg_kafka
[3] https://github.com/xstevens/decoderbufs
PS: There are a bunch of interesting MySQL solutions out there, such as Zendesk's Maxwell:
One thing I'd like to see is the ability to sanitize/munge data from the source cluster before it is sent to the destination cluster, for masking sensitive data in the source cluster (PCI, HIPAA, etc).
EDIT: doesn't really address your point b) however.
\copy (select whatever from whatever) to 'yourlocalfile.csv' with (format 'csv')
and if you want column headers, add a "header true" inside of the with clause.
Generally, \copy works just like COPY[1] but it does so from the remote server to the local machine, whereas file names given to COPY are relative to the server.
Yes. A dedicated tool might feel easier initially, but once you know how \copy works, you can always get a CSV file from whatever database you're connected to and no matter what machine you're on.
[1]: http://www.postgresql.org/docs/current/static/sql-copy.html
I'm not sure how good they are though.
It's a few gigabytes of data, compressed.
I can't vouch for the quality of most, but I know that Schönig's books usually are good.