Created
February 24, 2010 10:49
-
-
Save hugowetterberg/313324 to your computer and use it in GitHub Desktop.
Small script to dump all local mysql databases
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import os | |
import re | |
import subprocess | |
user="onlyme" | |
password="xxxxxxx" | |
proc = subprocess.Popen(["mysql", "-u" + user, "-p" + password], | |
stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr = subprocess.PIPE) | |
output, errors = proc.communicate("SHOW DATABASES") | |
for database in output.splitlines()[1:]: | |
if database != 'information_schema': | |
print "Dumping %s" % database | |
file = open("%s.sql" % database, 'w') | |
proc = subprocess.Popen(["mysqldump", "-u" + user, "-p" + password, database], | |
stdout=file) | |
proc.communicate() | |
file.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
It has been very useful, just what I needed. Thank you!!!