custom commands escaped
This commit is contained in:
parent
2b755d8ade
commit
9e3d19a406
1 changed files with 17 additions and 8 deletions
|
@ -1,6 +1,7 @@
|
||||||
import copy
|
import copy
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
|
import shlex
|
||||||
|
|
||||||
from borgmatic.execute import (
|
from borgmatic.execute import (
|
||||||
execute_command,
|
execute_command,
|
||||||
|
@ -35,9 +36,11 @@ def database_names_to_dump(database, extra_environment, log_prefix, dry_run):
|
||||||
if dry_run:
|
if dry_run:
|
||||||
return ()
|
return ()
|
||||||
|
|
||||||
mysql_show_command = database.get('mysql_command') or 'mysql'
|
mysql_show_command = tuple(
|
||||||
|
shlex.quote(part) for part in shlex.split(database.get('mysql_command') or 'mysql')
|
||||||
|
)
|
||||||
show_command = (
|
show_command = (
|
||||||
(mysql_show_command,)
|
mysql_show_command
|
||||||
+ (tuple(database['list_options'].split(' ')) if 'list_options' in database else ())
|
+ (tuple(database['list_options'].split(' ')) if 'list_options' in database else ())
|
||||||
+ (('--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 ())
|
||||||
|
@ -80,9 +83,11 @@ def execute_dump_command(
|
||||||
)
|
)
|
||||||
return None
|
return None
|
||||||
|
|
||||||
mysql_dump_command = database.get('mysql_dump_command') or 'mysqldump'
|
mysql_dump_command = tuple(
|
||||||
|
shlex.quote(part) for part in shlex.split(database.get('mysql_dump_command') or 'mysqldump')
|
||||||
|
)
|
||||||
dump_command = (
|
dump_command = (
|
||||||
(mysql_dump_command,)
|
mysql_dump_command
|
||||||
+ (tuple(database['options'].split(' ')) if 'options' in database else ())
|
+ (tuple(database['options'].split(' ')) if 'options' in database else ())
|
||||||
+ (('--add-drop-database',) if database.get('add_drop_database', True) else ())
|
+ (('--add-drop-database',) if database.get('add_drop_database', True) else ())
|
||||||
+ (('--host', database['hostname']) if 'hostname' in database else ())
|
+ (('--host', database['hostname']) if 'hostname' in database else ())
|
||||||
|
@ -208,9 +213,13 @@ def restore_data_source_dump(
|
||||||
password = connection_params['password'] or data_source.get(
|
password = connection_params['password'] or data_source.get(
|
||||||
'restore_password', data_source.get('password')
|
'restore_password', data_source.get('password')
|
||||||
)
|
)
|
||||||
mysql_restore_command = data_source.get('mysql_command') or 'mysql'
|
|
||||||
|
mysql_restore_command = tuple(
|
||||||
|
shlex.quote(part) for part in shlex.split(data_source.get('mysql_command') or 'mysql')
|
||||||
|
)
|
||||||
restore_command = (
|
restore_command = (
|
||||||
(mysql_restore_command, '--batch')
|
mysql_restore_command
|
||||||
|
+ ('--batch',)
|
||||||
+ (
|
+ (
|
||||||
tuple(data_source['restore_options'].split(' '))
|
tuple(data_source['restore_options'].split(' '))
|
||||||
if 'restore_options' in data_source
|
if 'restore_options' in data_source
|
||||||
|
|
Loading…
Reference in a new issue