PGCOPYDB SNAPSHOT(1) | pgcopydb | PGCOPYDB SNAPSHOT(1) |
pgcopydb snapshot - pgcopydb snapshot
pgcopydb snapshot - Create and export a snapshot on the source database
The command pgcopydb snapshot connects to the source database and executes a SQL query to export a snapshot. The obtained snapshot is both printed on stdout and also in a file where other pgcopydb commands might expect to find it.
pgcopydb snapshot: Create and export a snapshot on the source database usage: pgcopydb snapshot --source ... --source Postgres URI to the source database --dir Work directory to use --follow Implement logical decoding to replay changes --plugin Output plugin to use (test_decoding, wal2json) --wal2json-numeric-as-string Print numeric data type as string when using wal2json output plugin --slot-name Use this Postgres replication slot name
The following options are available to pgcopydb snapshot:
The replication slot is created using the Postgres replication protocol command CREATE_REPLICATION_SLOT, which then exports the snapshot being used in that command.
It is possible to use wal2json instead. The support for wal2json is mostly historical in pgcopydb, it should not make a user visible difference whether you use the default test_decoding or wal2json.
You need to have a wal2json plugin version on source database that supports --numeric-data-types-as-string option to use this option.
See also the documentation for wal2json regarding this option for details.
PGCOPYDB_SOURCE_PGURI
PGCOPYDB_OUTPUT_PLUGIN
PGCOPYDB_WAL2JSON_NUMERIC_AS_STRING
When --wal2json-numeric-as-string is ommitted from the command line then this environment variable is used.
Create a snapshot on the source database in the background:
$ pgcopydb snapshot & [1] 72938 17:31:52 72938 INFO Running pgcopydb version 0.7.13.gcbf2d16.dirty from "/Users/dim/dev/PostgreSQL/pgcopydb/./src/bin/pgcopydb/pgcopydb" 17:31:52 72938 INFO Using work dir "/var/folders/d7/zzxmgs9s16gdxxcm0hs0sssw0000gn/T//pgcopydb" 17:31:52 72938 INFO Removing the stale pid file "/var/folders/d7/zzxmgs9s16gdxxcm0hs0sssw0000gn/T//pgcopydb/pgcopydb.aux.pid" 17:31:52 72938 INFO Work directory "/var/folders/d7/zzxmgs9s16gdxxcm0hs0sssw0000gn/T//pgcopydb" already exists 17:31:52 72938 INFO Exported snapshot "00000003-000CB5FE-1" from the source database 00000003-000CB5FE-1
And when the process is done, stop maintaining the snapshot in the background:
$ kill %1 17:31:56 72938 INFO Asked to terminate, aborting [1]+ Done pgcopydb snapshot
Dimitri Fontaine
2022-2024, Dimitri Fontaine
January 10, 2024 | 0.15 |