Move mysqldump options to the beginning of the command due to MySQL bug 30994 (#470).

Reviewed-on: https://projects.torsion.org/borgmatic-collective/borgmatic/pulls/470
This commit is contained in:
Dan Helfman 2021-11-29 20:08:59 +00:00
commit c6f47d4d56
2 changed files with 2 additions and 2 deletions

View file

@ -82,12 +82,12 @@ def dump_databases(databases, log_prefix, location_config, dry_run):
dump_command = ( dump_command = (
('mysqldump',) ('mysqldump',)
+ (tuple(database['options'].split(' ')) if 'options' in database else ())
+ ('--add-drop-database',) + ('--add-drop-database',)
+ (('--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 ())
+ (('--protocol', 'tcp') if 'hostname' in database or 'port' in database else ()) + (('--protocol', 'tcp') if 'hostname' in database or 'port' in database else ())
+ (('--user', database['username']) if 'username' in database else ()) + (('--user', database['username']) if 'username' in database else ())
+ (tuple(database['options'].split(' ')) if 'options' in database else ())
+ ('--databases',) + ('--databases',)
+ dump_database_names + dump_database_names
# Use shell redirection rather than execute_command(output_file=open(...)) to prevent # Use shell redirection rather than execute_command(output_file=open(...)) to prevent

View file

@ -155,8 +155,8 @@ def test_dump_databases_runs_mysqldump_with_options():
flexmock(module).should_receive('execute_command').with_args( flexmock(module).should_receive('execute_command').with_args(
( (
'mysqldump', 'mysqldump',
'--add-drop-database',
'--stuff=such', '--stuff=such',
'--add-drop-database',
'--databases', '--databases',
'foo', 'foo',
'>', '>',