Repairing the MythTV Database
I’ve been pretty happy with MythDora over KnoppMyth overall (it’s actively maintained, for one thing), but like most MythTV setups, the MySQL database tends to crash with regular use, despite running the DB Optimize Script regularly.
After having to type (and re-type) a series of terminal commands, I finally just wrote a shell script to do everything automatically:
#!/bin/sh
service mythbackend stop
service mysqld stop
cd /var/lib/mysql/mythconverg
myisamchk *.MYI > crash.log 2>&1
grep corrupt crash.log | grep table | \
sed -e 's/ is corrupted//' | \
sed -e 's/MyISAM-table //' | \
sed -e "s/'//g" | \
sed -e 's/^/myisamchk -r /' > repair.sh
grep fixed crash.log | \
sed -e 's/ is usable but should be fixed//' | \
sed -e 's/MyISAM-table //' | \
sed -e "s/'//g" | \
sed -e 's/^/myisamchk -r /' >> repair.sh
sh repair.sh > repair.log 2>&1
myisamchk -c *.MYI > after.log 2>&1
echo "**** After repair ****"
grep -i fix after.log
grep -i corrupt after.log
mv *.log /tmp
mv *.sh /tmp
echo "**** Repair done ****"
echo "Check /tmp/after.log and if ok, run:"
echo " service mysqld start"
echo " service mythbackend start"
Ok, not quite everything, since the repair results should be checked (a simple grep for “fix” and “corrupt” suffices) before restarting the mythv services, but recovery is much easier now.
Tags: Building a DVR, HOW-TO, KnoppMyth, MySQL, MythDora







June 14th, 2012 at 9:46 pm
[...] ind this of help. Denis Papathanasiou is currently my hero with a script that he placed on his blog (denis.papathanasiou.org/?p=533). Running this script managed to fix my database that had lost access to all existing recordings and [...]
June 14th, 2012 at 10:04 pm
Thanks Denis, this script saved my bacon by retrieving all my previously recorded content and actually able to access the tuners that were not working anymore. Basically my database was corrupted and your script fixed it.
Now if only I can figure out how to enable 0.25 to change channels like my 0.24 version did and stop getting buffer overruns, I will be happy again.
June 15th, 2012 at 11:13 am
Peter,
I’m glad it was useful, though, admittedly it had more to do with understanding how MySQL works than MythTV per se.
I’m can’t help with your other question, though, since I’ve yet to upgrade to version 0.25; the MythTV wiki or mailing list may be more helpful.