Backup & restore
pg_dump and pg_restore work with xpatch tables, with two things to remember, install the extension first and run fix_restored_configs() after.
Backup & restore
xpatch tables go through pg_dump and pg_restore like any other table. The dump carries the row data, the internal _xp_seq values, and each table's configuration. There are exactly two things to get right: the target server needs the extension, and you run one fixup after the restore.
What ends up in the dump
- Row data and
_xp_seq. The internal_xp_seqvalues are dumped and restored too, so every version keeps its original sequence number and the restored table rebuilds the same version chains. - Per-table config. The
xpatch.table_configcatalog is registered to be dumped with the extension, so yourgroup_by,order_by, and compression settings travel with the data.
No special flags. A normal dump captures everything:
pg_dump -Fc mydb > mydb.dumpRestoring
Restore procedure
Install pg-xpatch on the target server first, so the access method exists when the dump recreates the tables:
# on the target, then in the target databasepsql -d newdb -c "CREATE EXTENSION IF NOT EXISTS pg_xpatch;"Restore the dump as usual:
pg_restore -d newdb mydb.dumpRemap the config to the restored tables:
SELECT xpatch.fix_restored_configs();pg-xpatch looks up a table's config by its OID, and OIDs change on restore. Until fix_restored_configs() re-links the config (by schema and table name), restored tables fall back to auto-detection, which can silently drop your group_by and mis-handle grouping. The call also clears configs for tables that no longer exist.
Moving config between databases
If you want the configuration on its own, for a migration script or to reapply it elsewhere, dump_configs() emits ready-to-run configure() statements:
SELECT * FROM xpatch.dump_configs();-- SELECT xpatch.configure('public.documents', group_by => 'doc_id', ...);-- SELECT xpatch.configure('public.notes', ...);Run that output against the target after loading the tables. This is the portable alternative when a plain catalog round-trip is not what you want.
Signatures for fix_restored_configs() and dump_configs().
What the restored config actually controls.
Hat das auf deinem Setup funktioniert?
Noch nicht bewertet