From c3e76585fcad1c17f0503a594045f1b4959e3c30 Mon Sep 17 00:00:00 2001 From: nebulon42 Date: Fri, 26 Nov 2021 17:16:03 +0100 Subject: [PATCH] move mysqldump options to the beginning of the command due to MySQL bug 30994. --- borgmatic/hooks/mysql.py | 2 +- tests/unit/hooks/test_mysql.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/borgmatic/hooks/mysql.py b/borgmatic/hooks/mysql.py index dbd51d881..399f17e7d 100644 --- a/borgmatic/hooks/mysql.py +++ b/borgmatic/hooks/mysql.py @@ -82,12 +82,12 @@ def dump_databases(databases, log_prefix, location_config, dry_run): dump_command = ( ('mysqldump',) + + (tuple(database['options'].split(' ')) if 'options' in database else ()) + ('--add-drop-database',) + (('--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 ()) + (('--user', database['username']) if 'username' in database else ()) - + (tuple(database['options'].split(' ')) if 'options' in database else ()) + ('--databases',) + dump_database_names # Use shell redirection rather than execute_command(output_file=open(...)) to prevent diff --git a/tests/unit/hooks/test_mysql.py b/tests/unit/hooks/test_mysql.py index 052b2effd..670000174 100644 --- a/tests/unit/hooks/test_mysql.py +++ b/tests/unit/hooks/test_mysql.py @@ -155,8 +155,8 @@ def test_dump_databases_runs_mysqldump_with_options(): flexmock(module).should_receive('execute_command').with_args( ( 'mysqldump', - '--add-drop-database', '--stuff=such', + '--add-drop-database', '--databases', 'foo', '>',