diff --git a/borgmatic/hooks/mysql.py b/borgmatic/hooks/mysql.py index 49e2ea0..0805e09 100644 --- a/borgmatic/hooks/mysql.py +++ b/borgmatic/hooks/mysql.py @@ -152,7 +152,7 @@ def restore_database_dump(database_config, log_prefix, location_config, dry_run, database = database_config[0] restore_command = ( - ('mysql', '--batch') + ('mysql', '--batch', '--verbose') + (('--host', database['hostname']) if 'hostname' in database else ()) + (('--port', str(database['port'])) if 'port' in database else ()) + (('--protocol', 'tcp') if 'hostname' in database or 'port' in database else ()) @@ -169,6 +169,7 @@ def restore_database_dump(database_config, log_prefix, location_config, dry_run, execute_command_with_processes( restore_command, [extract_process], + output_log_level=logging.DEBUG, input_file=extract_process.stdout, extra_environment=extra_environment, ) diff --git a/borgmatic/hooks/postgresql.py b/borgmatic/hooks/postgresql.py index 666540c..f50da7b 100644 --- a/borgmatic/hooks/postgresql.py +++ b/borgmatic/hooks/postgresql.py @@ -142,6 +142,7 @@ def restore_database_dump(database_config, log_prefix, location_config, dry_run, execute_command_with_processes( restore_command, [extract_process], + output_log_level=logging.DEBUG, input_file=extract_process.stdout, extra_environment=extra_environment, ) diff --git a/tests/unit/hooks/test_mysql.py b/tests/unit/hooks/test_mysql.py index abe8375..2b757c8 100644 --- a/tests/unit/hooks/test_mysql.py +++ b/tests/unit/hooks/test_mysql.py @@ -1,3 +1,5 @@ +import logging + import pytest from flexmock import flexmock @@ -201,8 +203,9 @@ def test_restore_database_dump_runs_mysql_to_restore(): extract_process = flexmock(stdout=flexmock()) flexmock(module).should_receive('execute_command_with_processes').with_args( - ('mysql', '--batch'), + ('mysql', '--batch', '--verbose'), processes=[extract_process], + output_log_level=logging.DEBUG, input_file=extract_process.stdout, extra_environment=None, ).once() @@ -232,6 +235,7 @@ def test_restore_database_dump_runs_mysql_with_hostname_and_port(): ( 'mysql', '--batch', + '--verbose', '--host', 'database.example.org', '--port', @@ -240,6 +244,7 @@ def test_restore_database_dump_runs_mysql_with_hostname_and_port(): 'tcp', ), processes=[extract_process], + output_log_level=logging.DEBUG, input_file=extract_process.stdout, extra_environment=None, ).once() @@ -254,8 +259,9 @@ def test_restore_database_dump_runs_mysql_with_username_and_password(): extract_process = flexmock(stdout=flexmock()) flexmock(module).should_receive('execute_command_with_processes').with_args( - ('mysql', '--batch', '--user', 'root'), + ('mysql', '--batch', '--verbose', '--user', 'root'), processes=[extract_process], + output_log_level=logging.DEBUG, input_file=extract_process.stdout, extra_environment={'MYSQL_PWD': 'trustsome1'}, ).once() diff --git a/tests/unit/hooks/test_postgresql.py b/tests/unit/hooks/test_postgresql.py index 68b551a..089f89a 100644 --- a/tests/unit/hooks/test_postgresql.py +++ b/tests/unit/hooks/test_postgresql.py @@ -1,3 +1,5 @@ +import logging + import pytest from flexmock import flexmock @@ -203,6 +205,7 @@ def test_restore_database_dump_runs_pg_restore(): 'foo', ), processes=[extract_process], + output_log_level=logging.DEBUG, input_file=extract_process.stdout, extra_environment=None, ).once() @@ -247,6 +250,7 @@ def test_restore_database_dump_runs_pg_restore_with_hostname_and_port(): '5433', ), processes=[extract_process], + output_log_level=logging.DEBUG, input_file=extract_process.stdout, extra_environment=None, ).once() @@ -289,6 +293,7 @@ def test_restore_database_dump_runs_pg_restore_with_username_and_password(): 'postgres', ), processes=[extract_process], + output_log_level=logging.DEBUG, input_file=extract_process.stdout, extra_environment={'PGPASSWORD': 'trustsome1'}, ).once() @@ -319,6 +324,7 @@ def test_restore_database_dump_runs_psql_for_all_database_dump(): flexmock(module).should_receive('execute_command_with_processes').with_args( ('psql', '--no-password'), processes=[extract_process], + output_log_level=logging.DEBUG, input_file=extract_process.stdout, extra_environment=None, ).once()