Postgres Refresh Logical Replication Subscription From Publisher On Multiple Hosts

I needed a way to refresh a postgres logical replication subscription on many hosts. I decided to write a python script to achieve this, it reads in a list of hostnames and executes the refresh against each host. The subscription names are part of the host name name and I have a master server that I can run psql against each host as postgres.

Here is the contents of the host file:

Here is what the logical replication subscriptions look like:

Here is the python code:

Here is the contents of the utils lib:

This is what it looks like when running:

Leave a Reply

Your email address will not be published. Required fields are marked *