Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/include/clone.rst
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,5 @@
--origin Use this Postgres replication origin node name
--endpos Stop replaying changes when reaching this LSN
--use-copy-binary Use the COPY BINARY format for COPY operations
--connection-retry-timeout Number of seconds to retry before connection times out

41 changes: 21 additions & 20 deletions docs/include/copy-db.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,25 @@
pgcopydb copy db: Copy an entire database from source to target
usage: pgcopydb copy db --source ... --target ... [ --table-jobs ... --index-jobs ... ]

--source Postgres URI to the source database
--target Postgres URI to the target database
--dir Work directory to use
--table-jobs Number of concurrent COPY jobs to run
--index-jobs Number of concurrent CREATE INDEX jobs to run
--restore-jobs Number of concurrent jobs for pg_restore
--drop-if-exists On the target database, clean-up from a previous run first
--roles Also copy roles found on source to target
--no-owner Do not set ownership of objects to match the original database
--no-acl Prevent restoration of access privileges (grant/revoke commands).
--no-comments Do not output commands to restore comments
--no-tablespaces Do not output commands to select tablespaces
--skip-large-objects Skip copying large objects (blobs)
--filters <filename> Use the filters defined in <filename>
--fail-fast Abort early in case of error
--restart Allow restarting when temp files exist already
--resume Allow resuming operations after a failure
--not-consistent Allow taking a new snapshot on the source database
--snapshot Use snapshot obtained with pg_export_snapshot
--use-copy-binary Use the COPY BINARY format for COPY operations
--source Postgres URI to the source database
--target Postgres URI to the target database
--dir Work directory to use
--table-jobs Number of concurrent COPY jobs to run
--index-jobs Number of concurrent CREATE INDEX jobs to run
--restore-jobs Number of concurrent jobs for pg_restore
--drop-if-exists On the target database, clean-up from a previous run first
--roles Also copy roles found on source to target
--no-owner Do not set ownership of objects to match the original database
--no-acl Prevent restoration of access privileges (grant/revoke commands).
--no-comments Do not output commands to restore comments
--no-tablespaces Do not output commands to select tablespaces
--skip-large-objects Skip copying large objects (blobs)
--filters <filename> Use the filters defined in <filename>
--fail-fast Abort early in case of error
--restart Allow restarting when temp files exist already
--resume Allow resuming operations after a failure
--not-consistent Allow taking a new snapshot on the source database
--snapshot Use snapshot obtained with pg_export_snapshot
--use-copy-binary Use the COPY BINARY format for COPY operations
--connection-retry-timeout Number of seconds to retry before connection times out

9 changes: 5 additions & 4 deletions docs/include/dump-roles.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
pgcopydb dump roles: Dump source database roles as custome file in work directory
usage: pgcopydb dump roles --source <URI>

--source Postgres URI to the source database
--target Directory where to save the dump files
--dir Work directory to use
--no-role-passwords Do not dump passwords for roles
--source Postgres URI to the source database
--target Directory where to save the dump files
--dir Work directory to use
--no-role-passwords Do not dump passwords for roles
--connection-retry-timeout Number of seconds to retry before connection times out

13 changes: 7 additions & 6 deletions docs/include/dump-schema.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@
pgcopydb dump schema: Dump source database schema as custom files in work directory
usage: pgcopydb dump schema --source <URI>

--source Postgres URI to the source database
--target Directory where to save the dump files
--dir Work directory to use
--skip-extensions Skip restoring extensions
--filters <filename> Use the filters defined in <filename>
--snapshot Use snapshot obtained with pg_export_snapshot
--source Postgres URI to the source database
--target Directory where to save the dump files
--dir Work directory to use
--skip-extensions Skip restoring extensions
--filters <filename> Use the filters defined in <filename>
--snapshot Use snapshot obtained with pg_export_snapshot
--connection-retry-timeout Number of seconds to retry before connection times out

17 changes: 9 additions & 8 deletions docs/include/list-table-parts.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@
pgcopydb list table-parts: List a source table copy partitions
usage: pgcopydb list table-parts --source ...

--source Postgres URI to the source database
--force Force fetching catalogs again
--schema-name Name of the schema where to find the table
--table-name Name of the target table
--split-tables-larger-than Size threshold to consider partitioning
--split-max-parts Maximum number of jobs for Same-table concurrency
--skip-split-by-ctid Skip the ctid split
--estimate-table-sizes Allow using estimates for relation sizes
--source Postgres URI to the source database
--force Force fetching catalogs again
--schema-name Name of the schema where to find the table
--table-name Name of the target table
--split-tables-larger-than Size threshold to consider partitioning
--split-max-parts Maximum number of jobs for Same-table concurrency
--skip-split-by-ctid Skip the ctid split
--estimate-table-sizes Allow using estimates for relation sizes
--connection-retry-timeout Number of seconds to retry before connection times out

5 changes: 3 additions & 2 deletions docs/include/ping.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
pgcopydb ping: Attempt to connect to the source and target instances
usage: pgcopydb ping --source ... --target ...

--source Postgres URI to the source database
--target Postgres URI to the target database
--source Postgres URI to the source database
--target Postgres URI to the target database
--connection-retry-timeout Number of seconds to retry before connection times out

27 changes: 14 additions & 13 deletions docs/include/restore-schema.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,18 @@
pgcopydb restore schema: Restore a database schema from custom files to target database
usage: pgcopydb restore schema --dir <dir> [ --source <URI> ] --target <URI>

--source Postgres URI to the source database
--target Postgres URI to the target database
--dir Work directory to use
--restore-jobs Number of concurrent jobs for pg_restore
--drop-if-exists On the target database, clean-up from a previous run first
--no-owner Do not set ownership of objects to match the original database
--no-acl Prevent restoration of access privileges (grant/revoke commands).
--no-comments Do not output commands to restore comments
--no-tablespaces Do not output commands to select tablespaces
--filters <filename> Use the filters defined in <filename>
--restart Allow restarting when temp files exist already
--resume Allow resuming operations after a failure
--not-consistent Allow taking a new snapshot on the source database
--source Postgres URI to the source database
--target Postgres URI to the target database
--dir Work directory to use
--restore-jobs Number of concurrent jobs for pg_restore
--drop-if-exists On the target database, clean-up from a previous run first
--no-owner Do not set ownership of objects to match the original database
--no-acl Prevent restoration of access privileges (grant/revoke commands).
--no-comments Do not output commands to restore comments
--no-tablespaces Do not output commands to select tablespaces
--filters <filename> Use the filters defined in <filename>
--restart Allow restarting when temp files exist already
--resume Allow resuming operations after a failure
--not-consistent Allow taking a new snapshot on the source database
--connection-retry-timeout Number of seconds to retry before connection times out

1 change: 1 addition & 0 deletions docs/include/snapshot.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@
--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
--connection-retry-timeout Number of seconds to retry before connection times out

1 change: 1 addition & 0 deletions docs/include/stream-setup.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,5 @@
--wal2json-numeric-as-string Print numeric data type as string when using wal2json output plugin
--slot-name Stream changes recorded by this slot
--origin Name of the Postgres replication origin
--connection-retry-timeout Number of seconds to retry before connection times out

16 changes: 16 additions & 0 deletions docs/ref/pgcopydb_clone.rst
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,18 @@ Here is an example implement the previous steps:
$ kill %1


Retry mechanism
^^^^^^^^^^^^^^^

When a connection to either the source or target database fails, the command will
attempt to reconnect several times before giving up. The maximum duration for these
retries is determined by the ``--connection-retry-timeout`` parameter, which
defaults to 60 seconds.

Before each retry, the command will attempt to fetch updated connection strings from
the ``.env`` file located in either ``${XDG_CONFIG_HOME}/pgcopydb/.env`` or
``${HOME}/.config/pgcopydb/.env``.

Options
-------

Expand Down Expand Up @@ -714,6 +726,10 @@ The following options are available to ``pgcopydb clone``:
Environment
-----------

Environment variables that begin with ``PGCOPYDB_`` can be set directly in the
environment or read from the ``.env`` file located in either
``${XDG_CONFIG_HOME}/pgcopydb/.env`` or ``${HOME}/.config/pgcopydb/.env``.

PGCOPYDB_SOURCE_PGURI

Connection string to the source Postgres instance. When ``--source`` is
Expand Down
4 changes: 4 additions & 0 deletions docs/ref/pgcopydb_compare.rst
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,10 @@ compare data`` subcommands:
Environment
-----------

Environment variables that begin with ``PGCOPYDB_`` can be set directly in the
environment or read from the ``.env`` file located in either
``${XDG_CONFIG_HOME}/pgcopydb/.env`` or ``${HOME}/.config/pgcopydb/.env``.

PGCOPYDB_SOURCE_PGURI

Connection string to the source Postgres instance. When ``--source`` is
Expand Down
4 changes: 4 additions & 0 deletions docs/ref/pgcopydb_copy.rst
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,10 @@ The following options are available to ``pgcopydb copy`` sub-commands:
Environment
-----------

Environment variables that begin with ``PGCOPYDB_`` can be set directly in the
environment or read from the ``.env`` file located in either
``${XDG_CONFIG_HOME}/pgcopydb/.env`` or ``${HOME}/.config/pgcopydb/.env``.

PGCOPYDB_SOURCE_PGURI

Connection string to the source Postgres instance. When ``--source`` is
Expand Down
4 changes: 4 additions & 0 deletions docs/ref/pgcopydb_dump.rst
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,10 @@ The following options are available to ``pgcopydb dump schema`` subcommand:
Environment
-----------

Environment variables that begin with ``PGCOPYDB_`` can be set directly in the
environment or read from the ``.env`` file located in either
``${XDG_CONFIG_HOME}/pgcopydb/.env`` or ``${HOME}/.config/pgcopydb/.env``.

PGCOPYDB_SOURCE_PGURI

Connection string to the source Postgres instance. When ``--source`` is
Expand Down
4 changes: 4 additions & 0 deletions docs/ref/pgcopydb_follow.rst
Original file line number Diff line number Diff line change
Expand Up @@ -504,6 +504,10 @@ The following options are available to ``pgcopydb follow``:
Environment
-----------

Environment variables that begin with ``PGCOPYDB_`` can be set directly in the
environment or read from the ``.env`` file located in either
``${XDG_CONFIG_HOME}/pgcopydb/.env`` or ``${HOME}/.config/pgcopydb/.env``.

PGCOPYDB_SOURCE_PGURI

Connection string to the source Postgres instance. When ``--source`` is
Expand Down
4 changes: 4 additions & 0 deletions docs/ref/pgcopydb_list.rst
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,10 @@ The following options are available to ``pgcopydb dump schema``:
Environment
-----------

Environment variables that begin with ``PGCOPYDB_`` can be set directly in the
environment or read from the ``.env`` file located in either
``${XDG_CONFIG_HOME}/pgcopydb/.env`` or ``${HOME}/.config/pgcopydb/.env``.

PGCOPYDB_SOURCE_PGURI

Connection string to the source Postgres instance. When ``--source`` is
Expand Down
4 changes: 4 additions & 0 deletions docs/ref/pgcopydb_restore.rst
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,10 @@ The following options are available to ``pgcopydb restore schema``:
Environment
-----------

Environment variables that begin with ``PGCOPYDB_`` can be set directly in the
environment or read from the ``.env`` file located in either
``${XDG_CONFIG_HOME}/pgcopydb/.env`` or ``${HOME}/.config/pgcopydb/.env``.

PGCOPYDB_TARGET_PGURI

Connection string to the target Postgres instance. When ``--target`` is
Expand Down
4 changes: 4 additions & 0 deletions docs/ref/pgcopydb_snapshot.rst
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,10 @@ The following options are available to ``pgcopydb snapshot``:
Environment
-----------

Environment variables that begin with ``PGCOPYDB_`` can be set directly in the
environment or read from the ``.env`` file located in either
``${XDG_CONFIG_HOME}/pgcopydb/.env`` or ``${HOME}/.config/pgcopydb/.env``.

PGCOPYDB_SOURCE_PGURI

Connection string to the source Postgres instance. When ``--source`` is
Expand Down
4 changes: 4 additions & 0 deletions docs/ref/pgcopydb_stream.rst
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,10 @@ The following options are available to ``pgcopydb stream`` sub-commands:
Environment
-----------

Environment variables that begin with ``PGCOPYDB_`` can be set directly in the
environment or read from the ``.env`` file located in either
``${XDG_CONFIG_HOME}/pgcopydb/.env`` or ``${HOME}/.config/pgcopydb/.env``.

PGCOPYDB_SOURCE_PGURI

Connection string to the source Postgres instance. When ``--source`` is
Expand Down
3 changes: 2 additions & 1 deletion src/bin/pgcopydb/blobs.c
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,8 @@ copydb_blob_worker(CopyDataSpec *specs)
bool dropIfExists = specs->restoreOptions.dropIfExists;

/* initialize our connection to the target database */
if (!pgsql_init(&dst, specs->connStrings.target_pguri, PGSQL_CONN_TARGET))
if (!pgsql_init(&dst, specs->connStrings.target_pguri, PGSQL_CONN_TARGET,
specs->connectionRetryTimeout))
{
/* errors have already been logged */
return false;
Expand Down
10 changes: 7 additions & 3 deletions src/bin/pgcopydb/cli_clone_follow.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
" --origin Use this Postgres replication origin node name\n" \
" --endpos Stop replaying changes when reaching this LSN\n" \
" --use-copy-binary Use the COPY BINARY format for COPY operations\n" \
" --connection-retry-timeout Number of seconds to retry before connection times out\n" \

CommandLine clone_command =
make_command(
Expand Down Expand Up @@ -212,7 +213,8 @@ clone_and_follow(CopyDataSpec *copySpecs)
&(copySpecs->catalogs.source),
copyDBoptions.stdIn,
copyDBoptions.stdOut,
logSQL))
logSQL,
copyDBoptions.connectionRetryTimeout))
{
/* errors have already been logged */
exit(EXIT_CODE_INTERNAL_ERROR);
Expand Down Expand Up @@ -390,7 +392,8 @@ cli_follow(int argc, char **argv)
&(copySpecs.catalogs.source),
copyDBoptions.stdIn,
copyDBoptions.stdOut,
logSQL))
logSQL,
copyDBoptions.connectionRetryTimeout))
{
/* errors have already been logged */
exit(EXIT_CODE_INTERNAL_ERROR);
Expand Down Expand Up @@ -562,7 +565,8 @@ cloneDB(CopyDataSpec *copySpecs)
if (!pg_copy_roles(&(copySpecs->pgPaths),
&(copySpecs->connStrings),
copySpecs->dumpPaths.rolesFilename,
copySpecs->noRolesPasswords))
copySpecs->noRolesPasswords,
copySpecs->connectionRetryTimeout))
{
/* errors have already been logged */
return false;
Expand Down
Loading