Skip to content

Instantly share code, notes, and snippets.

@a2f0
Created August 6, 2014 13:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save a2f0/f22b381ab71c4ac4576c to your computer and use it in GitHub Desktop.
Save a2f0/f22b381ab71c4ac4576c to your computer and use it in GitHub Desktop.
p = subprocess.Popen(["mysqldump", "--single-transaction", "-u",
database_username, "--password="+database_password, "--databases",
"--host", server_address, database_name, ],
stdout = open( outputfile, 'w') , stderr=subprocess.PIPE)
error = p.stderr.read()
p_ret = p.wait()
print "return code from mysqldump: " + str(p_ret)
if (len(error)) > 0:
action_error(error)
sys.exit(-1)
if (compress == "1"):
p2 = subprocess.Popen(["tar", "-C", backup_destination,
"--remove-files", "--force-local", "-czf", gzipoutputfile,
mysqlfilename ], stderr=subprocess.PIPE)
error2 = p2.stderr.read()
p2.wait()
if (len(error2)) > 0:
action_error(error2)
sys.exit(-1)
action_success()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment