Created
July 25, 2012 09:12
-
-
Save sagar-webonise/3175221 to your computer and use it in GitHub Desktop.
Python script for taking mysqldump
This file contains 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
--- created by sagar shirsath (sagars@weboniselab.com)--- | |
the file pydump contains python code for taking sql dump . | |
How to run : | |
Go to folder containing file pydump and run the following command | |
$python pydump.py | |
This file contains 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 ConfigParser | |
import os | |
import time | |
import getpass | |
def get_dump(): | |
print "Enter user:" | |
user = raw_input() | |
print "Password will not be visible:" | |
password = getpass.getpass() | |
print "Enter host:" | |
host = raw_input() | |
print "Enter database name:" | |
database = raw_input() | |
filestamp = time.strftime('%Y-%m-%d-%I:%M') | |
os.popen("mysqldump -u %s -p%s -h %s -e --opt -c %s | gzip -c > %s.gz" % (user,password,host,database,database+"_"+filestamp)) | |
print "\n-- please have a the dump file in "+database+"_"+filestamp+".gz --" | |
if __name__=="__main__": | |
get_dump() | |
Hey there,
Thanks for your effort.
I have upgraded the script to Python 3 here: https://github.com/gurutux/GuruTux/blob/master/MySQL/pydump.py
given link is not working(404)
Hey there,
Thanks for your effort.
I have upgraded the script to Python 3 here: https://github.com/gurutux/GuruTux/blob/master/MySQL/pydump.pygiven link is not working(404)
yes @gurutux can you check the link
Hey there,
Thanks for your effort.
I have upgraded the script to Python 3 here: https://github.com/gurutux/GuruTux/blob/master/MySQL/pydump.pygiven link is not working(404)
yes @gurutux can you check the link
Just go to his profile, it's there.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi Team,
I'm maintaining MySQL with 7 databases as per my application needs by excluding default dbs. Now I want one Python script to take mysql dump, it should give below requirements.