PGCOPYDB SNAPSHOT(1)
π PGCOPYDB SNAPSHOT(1) π
okay so bestie, welcome to section 1 of the manual β this is the pgcopydb snapshot page, and it's genuinely one of my faves because it's SO straightforward. she connects, she exports, she dips. icon behaviour fr fr. β¨
πΈ NAME πΈ
pgcopydb snapshot β pgcopydb snapshot
pgcopydb snapshot β Create and export a snapshot on the source database
The way that pgcopydb snapshot works is: it connects to your source database and runs a SQL query to export a snapshot. That snapshot? It gets printed on stdout AND written into a file, because that's where the other pgcopydb commands go looking for it. no cap. π«Ά
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 (pgoutput, 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
β¨ OPTIONS β¨
These are the options you get with pgcopydb snapshot, and yes, I'm giving you all of them, no gatekeeping π
--sourceβ the connection string for your source Postgres instance. peep the Postgres docs for connection strings <https://www.postgresql.org/docs/current/libpq-connect.html#LIBPQ-CONNSTRING> if you want the full tea. short version: both the quoted form"host=... dbname=..."and the URI formpostgres://user@host:5432/dbnameare supported. pick your fighter π--dirβ during normal operationspgcopydbcreates a LOT of temporary files, because it's tracking sub-processes progress and it's lowkey a little overachiever about it. those temp files live in the directory you pick here, or they default to${TMPDIR}/pgcopydbwhen the environment variable is set, or otherwise to/tmp/pgcopydb. π§--followβ when you pass--follow,pgcopydbimplements Change Data Capture as detailed in the manual page forpgcopydb follow<#id7>, running in parallel to the main copy database steps. the replication slot gets created with the Postgres replication protocol commandCREATE_REPLICATION_SLOT, which then exports the snapshot being used in that command. main character energy, honestly π--pluginβ the logical decoding output plugin to use. the default ispgoutput<https://www.postgresql.org/docs/current/protocol-logical-replication.html>, which is built right into PostgreSQL core (since Postgres 10) and needs ZERO extension installation on the source server. obsessed. β¨ you can also usetest_decoding<https://www.postgresql.org/docs/current/test-decoding.html> orwal2json<https://github.com/eulerto/wal2json/> β both are still supported for backwards compatibility. π¦--wal2json-numeric-as-stringβ when you're using thewal2jsonoutput plugin, you can pass this option to tellwal2jsonto output numeric values as strings, which prevents some precision loss. so important. β heads up though: you need awal2jsonplugin version on the source database that supports the--numeric-data-types-as-stringoption to be able to use this. and see also the docs forwal2json<https://github.com/eulerto/wal2json/pull/255> about this option for the details π--slot-nameβ the logical decoding slot name to use.--verboseβ bump up the current verbosity. default level isINFO. in ascending order,pgcopydbknows about these verbosity levels:FATAL,ERROR,WARN,INFO,NOTICE,DEBUG,TRACE. π--debugβ set current verbosity toDEBUGlevel.--traceβ set current verbosity toTRACElevel.--quietβ set current verbosity toERRORlevel. π€«
πΏ ENVIRONMENT πΏ
PGCOPYDB_SOURCE_PGURIβ connection string to the source Postgres instance. when--sourceis ommitted from the command line, then this environment variable is used. she's the backup plan and she delivers πPGCOPYDB_OUTPUT_PLUGINβ logical decoding output plugin to use. when--pluginis omitted from the command line, then this environment variable is used.PGCOPYDB_WAL2JSON_NUMERIC_AS_STRINGβ when it's true (oryes, oron, or1β same input as a Postgres boolean, so whatever flavour of truth you vibe with) thenpgcopydbuses thewal2jsonoption--numeric-data-types-as-stringwhen using thewal2jsonoutput plugin. and when--wal2json-numeric-as-stringis ommitted from the command line, then this environment variable is used. periodt. π
π EXAMPLES π
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
π¦ AUTHOR π¦
Dimitri Fontaine
π COPYRIGHT π
2022-2024, Dimitri Fontaine
okay that's the whole page bestie, you ate it up fr fr π β¨
made with love, pgcopydb version 0.18, dated Jun 28, 2026 β that's the tea, see you in the next manpage π«Άπ
π¦ where this page comes from
- ubuntu stonking: pgcopydb 0.18-1 Β· PostgreSQL
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms