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="")