no way to compare when less than two revisions
Unterschiede
Hier werden die Unterschiede zwischen zwei Versionen angezeigt.
Vorhergehende Überarbeitung | |||
— | it:linux:mysqldump_fehler_automatisch_beheben [2015/12/24 14:26] (aktuell) – Externe Bearbeitung 127.0.0.1 | ||
---|---|---|---|
Zeile 1: | Zeile 1: | ||
+ | ====== Mysqldump-Fehler automatisch beheben ====== | ||
+ | ===== Anzeichen ===== | ||
+ | Aus unerfindlichen Gruenden ist mysqldump der Meinung, dass in meiner Datenbank viel kaputt ist, und will keinen Dump mehr machen. | ||
+ | |||
+ | Man versucht <code bash> | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | |||
+ | ===== Loesung ===== | ||
+ | Folgendes Pythonscript behandelt die Fehler wie folgt: | ||
+ | * 1146: *.frm Datei (passende!) suchen und loeschen | ||
+ | * 1102: Datenbank Unterverzeichniss loeschen | ||
+ | * 1017: Tabelle per SQL Befehl DROP TABLE loeschen | ||
+ | |||
+ | <code python> | ||
+ | import os | ||
+ | import re | ||
+ | import subprocess | ||
+ | import fnmatch | ||
+ | import shutil | ||
+ | |||
+ | def invalidDatabase(output): | ||
+ | matches = re.findall(r" | ||
+ | if len(matches)==0: | ||
+ | return | ||
+ | for root, | ||
+ | for dirname in fnmatch.filter(dirnames, | ||
+ | print " | ||
+ | shutil.rmtree(root+dirname) | ||
+ | |||
+ | def invalidTable(output): | ||
+ | matches = re.findall(r" | ||
+ | dirname = '' | ||
+ | if len(matches) == 0: | ||
+ | return | ||
+ | if len(matches[0]) == 1: | ||
+ | tablename = matches[0] | ||
+ | if len(matches[0]) == 2: | ||
+ | dirname = matches[0][0] | ||
+ | tablename = matches[0][1] | ||
+ | print "Found table", | ||
+ | |||
+ | for root, | ||
+ | for filename in fnmatch.filter(filenames, | ||
+ | if dirname != '': | ||
+ | if dirname == root.split('/' | ||
+ | targetFile = root + '/' | ||
+ | print "Will delete", | ||
+ | os.remove(targetFile) | ||
+ | else: | ||
+ | targetFile = root + '/' | ||
+ | print "Will delete", | ||
+ | os.remove(targetFile) | ||
+ | |||
+ | def cantFindFile(output): | ||
+ | matches = re.findall(r" | ||
+ | if len(matches) == 0: | ||
+ | return | ||
+ | tablename = matches[0] | ||
+ | for root, | ||
+ | for filename in fnmatch.filter(filenames, | ||
+ | dirname = root.split('/' | ||
+ | print " | ||
+ | os.system(' | ||
+ | |||
+ | while True: | ||
+ | cmd = [' | ||
+ | p = subprocess.Popen(cmd, | ||
+ | p.wait() | ||
+ | output = p.stderr.read() | ||
+ | print " | ||
+ | invalidTable(output) | ||
+ | invalidDatabase(output) | ||
+ | cantFindFile(output) | ||
+ | |||
+ | </ |