Created
October 10, 2016 00:09
-
-
Save dotmanila/6b90b4817eac7fcbcf98c2e7d8bdd484 to your computer and use it in GitHub Desktop.
Dump data from a crashing MySQL server with corrupt pages.
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 | |
pid_file_path=/var/lib/mysql/mysqld.pid | |
for d in $(cat dbs-list.txt); do | |
#if ! grep $d important-dbs.txt; then continue; fi | |
mysql $d -BNe 'show tables' > /tmp/tables.txt | |
for t in $(cat /tmp/tables.txt); do | |
while true; do | |
test -s "$pid_file_path" && break | |
sleep 10 && echo "Waiting for server PID" | |
done | |
while true; do | |
if ! mysqladmin ping > /dev/null 2>&1; then | |
sleep 10 && echo "Waiting for ping response" | |
else | |
break | |
fi | |
done | |
echo $d.$t | |
mysqldump --events --triggers -R $d $t > /dumps/$d.$t.dmp | |
done | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment