Skip to content

Instantly share code, notes, and snippets.

@lqez
Created July 30, 2012 10:44
Show Gist options
  • Select an option

  • Save lqez/3206140 to your computer and use it in GitHub Desktop.

Select an option

Save lqez/3206140 to your computer and use it in GitHub Desktop.
MySQL progressive restore
#!/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