Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Replicate selected postgresql tables between two servers?

What would be the best way to replicate individual DB tables from a Master postgresql server to a slave machine? It can be done with cron+rsync, or with whatever postgresql might have build in, or some sort of OSS tool, but so far the postgres docs don't seem to cover how to do table replication. I'm not able to do a full DB replication because some tables have license->IP stuff connected to it, and I can't replicate those on the slave machine. I don't need instant replication, hourly would be acceptable as well.

If I need to just rsync, can someone help identify what files within the /var/lib/pgsql directory would need to be synced, or how I would know what tables they are.

like image 977
Michael Guthrie Avatar asked Aug 15 '12 21:08

Michael Guthrie


People also ask

How do you replicate a table in PostgreSQL?

An example of logical replication You can either add all tables or choose to add selected tables to the publication. CREATE SUBSCRIPTION percsub CONNECTION 'host=publisher_server_ip dbname=percona user=postgres password=secret port=5432' The above command also copies the pre-existing data from the tables.

What is synchronous replication in PostgreSQL?

Synchronous replication offers the ability to confirm that all changes made by a transaction have been transferred to one or more synchronous standby servers. This extends that standard level of durability offered by a transaction commit.

Does Postgres have replication?

There are mainly two modes of PostgreSQL replication: synchronous and asynchronous. Synchronous replication allows data to be written to both the primary and secondary server at the same time, whereas asynchronous replication ensures that the data is first written to the host and then copied to the secondary server.


1 Answers

You might want to try Bucardo, which is an open source software to synchronize rows between tables even if they are in a remote location. It's a very simple software, and it is capable of creating one-way synchronization relationships as well.

Check out http://bucardo.org/wiki/Bucardo

like image 141
belidzs Avatar answered Oct 04 '22 01:10

belidzs