From 6a82b05e2e078219e03be61b9dfd08a7151afcbd Mon Sep 17 00:00:00 2001 From: Maxwell Muoto <41130755+max-muoto@users.noreply.github.com> Date: Tue, 31 Dec 2024 16:08:44 -0600 Subject: [PATCH] Set pipefail --- pgclone/dump_cmd.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/pgclone/dump_cmd.py b/pgclone/dump_cmd.py index 9b64033..dfb69d4 100644 --- a/pgclone/dump_cmd.py +++ b/pgclone/dump_cmd.py @@ -42,8 +42,11 @@ def _dump(*, exclude, config, pre_dump_hooks, instance, database, storage_locati [f"--exclude-table-data={table_name}" for table_name in exclude_tables] ) # Note - do note format {db_dump_url} with an `f` string. - # It will be formatted later when running the command - pg_dump_cmd_fmt = "pg_dump -Fc --no-acl --no-owner {db_dump_url} " + exclude_args + # It will be formatted later when running the command. + # Set -o pipefail to ensure that the pipeline fails if any command in it fails. + pg_dump_cmd_fmt = ( + "set -o pipefail; pg_dump -Fc --no-acl --no-owner {db_dump_url} " + exclude_args + ) pg_dump_cmd_fmt += " " + storage_client.pg_dump(file_path) anon_pg_dump_cmd = pg_dump_cmd_fmt.format(db_dump_url="")