Skip to content

Commit

Permalink
add arg_per_database. Fixes #180
Browse files Browse the repository at this point in the history
  • Loading branch information
Steven Soulen committed Nov 7, 2018
1 parent 00a9955 commit 85f9856
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import csv
import errno
import logging
import json
from holland.core.backup import BackupError
from holland.lib.safefilename import encode
from holland.backup.mysqldump.command import ALL_DATABASES, MySQLDumpError
Expand All @@ -27,7 +28,8 @@ def start(mysqldump,
lock_method='auto-detect',
file_per_database=True,
open_stream=open,
compression_ext=''):
compression_ext='',
arg_per_database=None):
"""Run a mysqldump backup"""
if not schema and file_per_database:
raise BackupError("file_per_database specified without a valid schema")
Expand All @@ -47,6 +49,8 @@ def start(mysqldump,
write_manifest(schema, open_stream, compression_ext)

if file_per_database:
if arg_per_database:
arg_per_database = json.loads(arg_per_database)
flush_logs = '--flush-logs' in mysqldump.options
if flush_logs:
mysqldump.options.remove('--flush-logs')
Expand All @@ -65,6 +69,8 @@ def start(mysqldump,
raise BackupError("Failed to open output stream %s: %s" %
( db_name + '.sql' + compression_ext, str(exc)))
try:
if db_name in arg_per_database:
more_options.append(arg_per_database[db_name])
mysqldump.run([db.name], stream, more_options)
finally:
try:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@
bin-log-position = boolean(default=no)
file-per-database = boolean(default=yes)
#arg-per-database is only used if file-per-database is true
## takes a json object {"table1": "--arg", "table2": "--arg"}
arg-per-database = string(default={})
additional-options = force_list(default=list())
Expand Down Expand Up @@ -240,7 +243,8 @@ def _backup(self):
lock_method=config['lock-method'],
file_per_database=config['file-per-database'],
open_stream=self._open_stream,
compression_ext=ext)
compression_ext=ext,
arg_per_database=config['arg-per-database'])
except MySQLDumpError as exc:
raise BackupError(str(exc))

Expand Down

0 comments on commit 85f9856

Please sign in to comment.