Skip to content

Instantly share code, notes, and snippets.

@dotmanila
Created October 10, 2016 00:09
Show Gist options
  • Save dotmanila/6b90b4817eac7fcbcf98c2e7d8bdd484 to your computer and use it in GitHub Desktop.
Save dotmanila/6b90b4817eac7fcbcf98c2e7d8bdd484 to your computer and use it in GitHub Desktop.
Dump data from a crashing MySQL server with corrupt pages.
#!/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