Browse Source

Make database restore output only show at verbosity 2.

Dan Helfman 5 years ago
parent
commit
4b523f9e2c

+ 2 - 1
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,
     )

+ 1 - 0
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,
     )

+ 8 - 2
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()

+ 6 - 0
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()