|
|
|
@ -124,7 +124,12 @@ def db_dump(module, host, user, password, db_name, target, socket=None):
|
|
|
|
|
else:
|
|
|
|
|
cmd += " --host=%s" % host
|
|
|
|
|
cmd += " %s" % db_name
|
|
|
|
|
cmd += " > %s" % target
|
|
|
|
|
if os.path.splitext(target)[-1] == '.gz':
|
|
|
|
|
cmd = cmd + ' | gzip > ' + target
|
|
|
|
|
elif os.path.splitext(target)[-1] == '.bz2':
|
|
|
|
|
cmd = cmd + ' | bzip2 > ' + target
|
|
|
|
|
else:
|
|
|
|
|
cmd += " > %s" % target
|
|
|
|
|
rc, stdout, stderr = module.run_command(cmd)
|
|
|
|
|
return rc, stdout, stderr
|
|
|
|
|
|
|
|
|
@ -136,7 +141,12 @@ def db_import(module, host, user, password, db_name, target, socket=None):
|
|
|
|
|
else:
|
|
|
|
|
cmd += " --host=%s" % host
|
|
|
|
|
cmd += " -D %s" % db_name
|
|
|
|
|
cmd += " < %s" % target
|
|
|
|
|
if os.path.splitext(target)[-1] == '.gz':
|
|
|
|
|
cmd = 'gunzip < ' + target + ' | ' + cmd
|
|
|
|
|
elif os.path.splitext(target)[-1] == '.bz2':
|
|
|
|
|
cmd = 'bunzip2 < ' + target + ' | ' + cmd
|
|
|
|
|
else:
|
|
|
|
|
cmd += " < %s" % target
|
|
|
|
|
rc, stdout, stderr = module.run_command(cmd)
|
|
|
|
|
return rc, stdout, stderr
|
|
|
|
|
|
|
|
|
|