From a1673d1fa121d6ef7a8904dea01a78a9baed86b7 Mon Sep 17 00:00:00 2001 From: Dan Helfman Date: Wed, 8 Dec 2021 16:40:25 -0800 Subject: [PATCH] Fix unicode error when restoring particular MySQL databases (#476). --- NEWS | 1 + borgmatic/hooks/mysql.py | 2 +- tests/unit/hooks/test_mysql.py | 5 ++--- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/NEWS b/NEWS index e960869..350af32 100644 --- a/NEWS +++ b/NEWS @@ -2,6 +2,7 @@ * #470: Move mysqldump options to the beginning of the command due to MySQL bug 30994. * #471: When command-line configuration override produces a parse error, error cleanly instead of tracebacking. + * #476: Fix unicode error when restoring particular MySQL databases. 1.5.21 * #28: Optionally retry failing backups via "retries" and "retry_wait" configuration options. diff --git a/borgmatic/hooks/mysql.py b/borgmatic/hooks/mysql.py index 399f17e..96031cb 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', '--verbose') + ('mysql', '--batch') + (('--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 ()) diff --git a/tests/unit/hooks/test_mysql.py b/tests/unit/hooks/test_mysql.py index 6700001..329c0ab 100644 --- a/tests/unit/hooks/test_mysql.py +++ b/tests/unit/hooks/test_mysql.py @@ -234,7 +234,7 @@ 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', '--verbose'), + ('mysql', '--batch'), processes=[extract_process], output_log_level=logging.DEBUG, input_file=extract_process.stdout, @@ -267,7 +267,6 @@ def test_restore_database_dump_runs_mysql_with_hostname_and_port(): ( 'mysql', '--batch', - '--verbose', '--host', 'database.example.org', '--port', @@ -292,7 +291,7 @@ 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', '--verbose', '--user', 'root'), + ('mysql', '--batch', '--user', 'root'), processes=[extract_process], output_log_level=logging.DEBUG, input_file=extract_process.stdout,