Created
June 3, 2016 10:49
-
-
Save xxorax/d8d1c612cf6a011120e4be96e1600b9c to your computer and use it in GitHub Desktop.
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
#!/bin/bash | |
# Author: Martin PANEL | |
# Description: find all crashed mysql table from a log file, a run request to repair them | |
# Usage : mysqlRepairTableFromLog.sh [logFile] | |
# logFile: file log or /var/log/syslog by default | |
# | |
# env var $MYSQL_OPTS can be used to add mysql params | |
# | |
log=/var/log/syslog | |
if [ ! -z "$1" ]; then | |
log="$1" | |
fi | |
tables="$(grep -i crashed "$log" | grep -i mysql | sed -r 's/.*Table ...(.+). is marked .+/\1/' | sort -u)" | |
request="repair table $(echo "$tables" | tr '\/\n' '.,' | sed 's/.$//');" | |
echo "$request" | mysql $MYSQL_OPTS |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment