Advertisement
Guest User

Untitled

a guest
Aug 19th, 2017
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. #!/usr/local/bin/python3
  2.  
  3. """
  4. Will backup all the databases listed, will put files in same DIR as script
  5. """
  6.  
  7. import ConfigParser
  8. import os
  9. import time
  10. import getpass
  11.  
  12. HOST='localhost'
  13. PORT='3306'
  14. DB_USER='username'
  15. DB_PASS='password'
  16. databases=('database1','database2','database3')
  17.  
  18. def get_dump(database):
  19. filestamp = time.strftime('%Y-%m-%d-%I')
  20. os.popen("mysqldump -h %s -P %s -u %s -p%s %s > %s.sql" % (HOST,PORT,DB_USER,DB_PASS,database,database+"_"+filestamp))
  21.  
  22. print "\n-- please have a the dump file in "+database+"_"+filestamp+".sql --"
  23.  
  24.  
  25. if __name__=="__main__":
  26. for database in databases:
  27. get_dump(database)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement