Created
July 30, 2012 10:44
-
-
Save lqez/3206140 to your computer and use it in GitHub Desktop.
MySQL progressive restore
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/python | |
| import glob | |
| import os | |
| import re | |
| from datetime import datetime | |
| mysql_username = "root" | |
| mysql_password = "password" | |
| mysql_conf = "my.cnf" | |
| mysql_cmd_start = "./dummy_start.py" | |
| mysql_cmd_stop = "./dummy_stop.py" | |
| indir = "/var/lib/mysql/" | |
| def escape_table(tablename): | |
| return tablename.replace("%","\%").replace("_","\_") | |
| def start_mysql(): | |
| print datetime.now(), "Starting MySQL... ", | |
| os.system(mysql_cmd_start) | |
| print "started." | |
| def stop_mysql(): | |
| print datetime.now(), "Stopping MySQL... ", | |
| os.system(mysql_cmd_stop) | |
| print "stopped." | |
| que = open(os.path.join(indir, 'que.log'), "r" ) | |
| while True: | |
| res = que.readline() | |
| if len(res) == 0: | |
| break; | |
| stop_mysql() | |
| print res | |
| start_mysql() | |
| que.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment