Permalink
Browse files

allow substituion of ${backup_directory} in xtrabackup's pre-command …

…option
  • Loading branch information...
1 parent 94db18b commit aa89a8c9f9576edb2141f38bdcf19e257fa63157 @abg abg committed Jan 9, 2013
@@ -148,7 +148,8 @@ def backup(self):
# innobackupex --tmpdir does not affect xtrabackup
util.add_xtrabackup_defaults(self.defaults_path, tmpdir=tmpdir)
args = util.build_xb_args(xb_cfg, backup_directory, self.defaults_path)
- util.execute_pre_command(xb_cfg['pre-command'])
+ util.execute_pre_command(xb_cfg['pre-command'],
+ backup_directory=backup_directory)
stderr = self.open_xb_logfile()
try:
stdout = self.open_xb_stdout()
@@ -8,6 +8,7 @@
import codecs
import tempfile
import logging
+from string import Template
from os.path import join, isabs, expanduser
from subprocess import Popen, PIPE, STDOUT, list2cmdline
from holland.core.backup import BackupError
@@ -136,10 +137,12 @@ def evaluate_tmpdir(tmpdir=None, basedir=None):
return tmpdir
-def execute_pre_command(pre_command):
+def execute_pre_command(pre_command, **kwargs):
"""Execute a pre-command"""
if not pre_command:
return
+
+ pre_command = Template(pre_command).safe_substitute(**kwargs)
try:
process = Popen(pre_command,
stdout=PIPE,

0 comments on commit aa89a8c

Please sign in to comment.