Dump pglogical Config to files

Posted on

Question :

We use the tool etckeeper to keep track of the configuration of servers.

I would like to dump the configuration of pglogical to files for this purpose.

I tried this:

db@host:~$ pg_dump -t 'pglogical.replication_set'

But the output looks empty:

-- PostgreSQL database dump

-- Dumped from database version 11.5
-- Dumped by pg_dump version 11.5

SET statement_timeout = 0;
SET lock_timeout = 0;
SET idle_in_transaction_session_timeout = 0;
SET client_encoding = 'UTF8';
SET standard_conforming_strings = on;
SELECT pg_catalog.set_config('search_path', '', false);
SET check_function_bodies = false;
SET xmloption = content;
SET client_min_messages = warning;
SET row_security = off;

-- PostgreSQL database dump complete

How can I dump the configuration of pglogical?

Use Case:

  • dump it hourly and store it in git to see what was changed.
  • compare two hosts to see if the configuration is equal.

Answer :

The table belongs to the extension pglogical, so pg_dump doesn’t dump it.

Objects that belong to an extension don’t get included in the dump, they are subsumed in the CREATE EXTENSION command from a database dump, because that object will be created by the CREATE EXTENSION command. If the object itself got dumped too, restoring the dump would cause an error, because the object already exists after CREATE EXTENSION.

You could use psql and do something like

copy (SELECT * FROM pglogical.replication_set ORDER BY ...) TO 'some.file' (FORMAT 'csv')

Leave a Reply

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