2
0
Эх сурвалжийг харах

Exit on error when restoring all PostgreSQL databases

"--set ON_ERROR_STOP=on" is equivalent to "--exit-on-error" in
pg_restore.
Jakub Jirutka 2 жил өмнө
parent
commit
dfccc1b94a

+ 1 - 1
borgmatic/hooks/postgresql.py

@@ -223,7 +223,7 @@ def restore_database_dump(database_config, log_prefix, location_config, dry_run,
         + (
         + (
             ('--if-exists', '--exit-on-error', '--clean', '--dbname', database['name'])
             ('--if-exists', '--exit-on-error', '--clean', '--dbname', database['name'])
             if not all_databases
             if not all_databases
-            else ('--no-psqlrc',)
+            else ('--no-psqlrc', '--set', 'ON_ERROR_STOP=on')
         )
         )
         + (('--host', database['hostname']) if 'hostname' in database else ())
         + (('--host', database['hostname']) if 'hostname' in database else ())
         + (('--port', str(database['port'])) if 'port' in database else ())
         + (('--port', str(database['port'])) if 'port' in database else ())

+ 1 - 1
tests/unit/hooks/test_postgresql.py

@@ -607,7 +607,7 @@ def test_restore_database_dump_runs_psql_for_all_database_dump():
     flexmock(module).should_receive('make_dump_path')
     flexmock(module).should_receive('make_dump_path')
     flexmock(module.dump).should_receive('make_database_dump_filename')
     flexmock(module.dump).should_receive('make_database_dump_filename')
     flexmock(module).should_receive('execute_command_with_processes').with_args(
     flexmock(module).should_receive('execute_command_with_processes').with_args(
-        ('psql', '--no-password', '--no-psqlrc'),
+        ('psql', '--no-password', '--no-psqlrc', '--set', 'ON_ERROR_STOP=on'),
         processes=[extract_process],
         processes=[extract_process],
         output_log_level=logging.DEBUG,
         output_log_level=logging.DEBUG,
         input_file=extract_process.stdout,
         input_file=extract_process.stdout,