Commit 71e3b7c2 authored by Antoine Catton's avatar Antoine Catton

Final improvement of mydumper

parent 82f3ee6a
...@@ -29,20 +29,53 @@ import subprocess ...@@ -29,20 +29,53 @@ import subprocess
from slapos.recipe.librecipe import GenericBaseRecipe from slapos.recipe.librecipe import GenericBaseRecipe
def dump(args): def dump(args):
mydumper_binary = args['mydumper'] mydumper_cmd = [args['mydumper']]
database = args['database'] mydumper_cmd.extend(['-B', args['database']])
socket = args['socket']
directory = args['directory'] if args['socket'] is not None:
mydumper_cmd.extend(['-S', args['socket']])
mydumper_cmd = [mydumper_binary, else:
'-B', database, mydumper_cmd.extend(['-h', args['host']])
'-u', 'root', mydumper_cmd.etxned(['-P', args['port']])
'-S', socket,
'-o', directory, mydumper_cmd.extend(['-u', args['user']])
] if args['password'] is not None:
mydumper_cmd.extend(['-p', args['password']])
if args['compression']:
mydumper_cmd.append('--compress')
if args['rows'] is not None:
mydumper_cmd.extend(['-r', args['rows']])
mydumper_cmd.extend(['-o', args['directory']])
subprocess.check_call(mydumper_cmd) subprocess.check_call(mydumper_cmd)
def do_import(args):
mydumper_cmd = [args['mydumper']]
mydumper_cmd.extend(['-B', args['database']])
if args['socket'] is not None:
mydumper_cmd.extend(['-S', args['socket']])
else:
mydumper_cmd.extend(['-h', args['host']])
mydumper_cmd.etxned(['-P', args['port']])
mydumper_cmd.extend(['-u', args['user']])
if args['password'] is not None:
mydumper_cmd.extend(['-p', args['password']])
mydumper_cmd.append('--overwrite-tables')
mydumper_cmd.extend(['-d', args['directory']])
subprocess.check_call(mydumper_cmd)
class Recipe(GenericBaseRecipe): class Recipe(GenericBaseRecipe):
def install(self): def install(self):
...@@ -59,7 +92,6 @@ class Recipe(GenericBaseRecipe): ...@@ -59,7 +92,6 @@ class Recipe(GenericBaseRecipe):
directory=self.options['backup-directory'], directory=self.options['backup-directory'],
user=self.options['user'], user=self.options['user'],
password=self.options.get('password'), password=self.options.get('password'),
compression=self.optionIsTrue('compression', default=False)
) )
name = __name__ name = __name__
...@@ -67,7 +99,10 @@ class Recipe(GenericBaseRecipe): ...@@ -67,7 +99,10 @@ class Recipe(GenericBaseRecipe):
config.update(mydumper=self.options['myloader-binary']) config.update(mydumper=self.options['myloader-binary'])
name += '.do_import' name += '.do_import'
else: else:
config.update(mydumper=self.options['mydumper-binary']) config.update(mydumper=self.options['mydumper-binary'],
compression=self.optionIsTrue('compression', default=False),
rows=self.options.get('rows'),
)
name += '.dump' name += '.dump'
wrapper = self.createPythonScript(self.options['wrapper'], wrapper = self.createPythonScript(self.options['wrapper'],
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment