Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/local/bin/python3
- """
- Will backup all the databases listed, will put files in same DIR as script
- """
- import ConfigParser
- import os
- import time
- import getpass
- HOST='localhost'
- PORT='3306'
- DB_USER='username'
- DB_PASS='password'
- databases=('database1','database2','database3')
- def get_dump(database):
- filestamp = time.strftime('%Y-%m-%d-%I')
- os.popen("mysqldump -h %s -P %s -u %s -p%s %s > %s.sql" % (HOST,PORT,DB_USER,DB_PASS,database,database+"_"+filestamp))
- print "\n-- please have a the dump file in "+database+"_"+filestamp+".sql --"
- if __name__=="__main__":
- for database in databases:
- get_dump(database)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement