Fix unicode error when restoring particular MySQL databases (#476).

This commit is contained in:
Dan Helfman 2021-12-08 16:40:25 -08:00
parent 2e99a1898c
commit a1673d1fa1
3 changed files with 4 additions and 4 deletions

1
NEWS
View file

@ -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.

View file

@ -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 ())

View file

@ -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,