pgcopydb configuration

Manual page for the configuration of pgcopydb. The pgcopydb command accepts sub-commands and command line options, see the manual for those commands for details. The only setup that pgcopydb commands accept is the filtering.

Filtering

Filtering allows to skip some object definitions and data when copying from the source to the target database. The pgcopydb commands that accept the option --filter (or --filters) expect an existing filename as the option argument. The given filename is read in the INI file format, but only uses sections and option keys. Option values are not used.

Here is an inclusion based filter configuration example:

 1[include-only-table]
 2public.allcols
 3public.csv
 4public.serial
 5public.xzero
 6
 7[exclude-index]
 8public.foo_gin_tsvector
 9
10[exclude-table-data]
11public.csv

Here is an exclusion based filter configuration example:

 1[exclude-schema]
 2foo
 3bar
 4expected
 5
 6[exclude-table]
 7"schema"."name"
 8schema.othername
 9err.errors
10public.serial
11
12[exclude-index]
13schema.indexname
14
15[exclude-table-data]
16public.bar
17nsitra.test1

Filtering can be done with pgcopydb by using the following rules, which are also the name of the sections of the INI file.

include-only-table

This section allows listing the exclusive list of the source tables to copy to the target database. No other table will be processed by pgcopydb.

Each line in that section should be a schema-qualified table name. Postgres identifier quoting rules can be used to avoid ambiguity.

When the section include-only-table is used in the filtering configuration then the sections exclude-schema and exclude-table are disallowed. We would not know how to handle tables that exist on the source database and are not part of any filter.

exclude-schema

This section allows adding schemas (Postgres namespaces) to the exclusion filters. All the tables that belong to any listed schema in this section are going to be ignored by the pgcopydb command.

This section is not allowed when the section include-only-table is used.

include-only-schema

This section allows editing schema (Postgres namespaces) to the exclusion filters by listing the schema that are not going to be excluded. This is a syntaxic sugar facility that helps with entering a long list of schemas to exclude when a single schema is to be selected.

Despite the name, this section is an exclusion filter.

This section is not allowed when the section exclude-schema is used.

exclude-table

This section allows to add a list of qualified table names to the exclusion filters. All the tables that are listed in the exclude-table section are going to be ignored by the pgcopydb command.

This section is not allowed when the section include-only-table is used.

exclude-index

This section allows to add a list of qualified index names to the exclusion filters. It is then possible for pgcopydb to operate on a table and skip a single index definition that belong to a table that is still processed.

exclude-table-data

This section allows to skip copying the data from a list of qualified table names. The schema, index, constraints, etc of the table are still copied over.

Reviewing and Debugging the filters

Filtering a pg_restore archive file is done through rewriting the archive catalog obtained with pg_restore --list. That’s a little hackish at times, and we also have to deal with dependencies in pgcopydb itself.

The following commands can be used to explore a set of filtering rules: