[mythtv-users] MythTV Disaster Recovery

R. G. Newbury newbury at mandamus.org
Tue Nov 17 02:10:09 UTC 2009

John Welch wrote:
> I'm almost embarrassed to post this because of some stupidity on my part 
> but here goes... Over the weekend I experienced a somewhat sudden and 
> what looks to be an unrecoverable hard drive crash on my boot / root 
> drive on my MythTV back-end system.  I had a fairly recent database 
> back-up from when I upgraded my system from 0.21 to 0.22 but 
> unfortunately (and foolishly) I left the backup not only on the back-end 
> system, but also on the root drive that crashed.  I dug around my other 
> systems and I did manage to find a previous database backup from earlier 
> in the year when I did a hardware upgrade.  Fortunately (I hope) I did 
> not lose any of my active recordings because they were being saved to 
> either another local drive or an NFS mount on my NAS server.

> So, now I am trying to figure out how to proceed.  My first question is 
> is it worth it to even attempt to use the database backup from earlier 
> in the year?  The biggest thing I dread is re-setting up my channel 
> lineups.  I haven't done much with the channel setup since 0.20 / early 
> 0.21 days, but I remember it to be a fairly time-consuming, very much 
> manual process.  Have things improved in this area so that it would now 
> be a trivial / painless process?  I'm particularly interested in QAM 
> channel scanning for the HDHR and pcHD3000 tuners.

If your upgrade to .22 was (relatively) painless then the old database 
should have the same channel setup/structure. So you should be able to 
skip that. Just re-install myth, stop mysqld and copy over the old 
database. On restart, myth should upgrade the schema.
You will end up with a database that does not know anything about the 
last year.

> Second, once I have MythTV set-up again is there any way for me to get 
> the recordings that I still have back into the database?  I did a search 
> of the mailing list archives and came up with a few older hits 
> mentioning the myth.rebuilddatabase.pl <http://myth.rebuilddatabase.pl> 
> script, but at least one reply seemed to indicate that it didn't really 
> update the database.

Myth.rebuilddatabase.pl does work to re-add the video files into the 
database. However, it does not 'know' what the files represent. It uses 
the channel+date+time file name. *IF* you know what the file represents, 
you can enter the info. (Or you can do that later using phpMyAdmin while 
looking at the files to determine what each is.
There is one problem with the myth.rebuilddatabase script. It leaves the 
file *size* as zero bytes, so myth chokes.
So in addition you need to run this little scriptlet, one file at a time 
using the filename on the command line, as in:

myth.rebuild.filesize.sh  1061_20090416215800.mpg

********** myth.rebuild.filesize.sh *******
# Taken from an anonymous post on the mythtv wiki.
# Thanks due to whoever you are, not Geoff Newbury!

SIZE=`ls -l $1 | awk '{print $5}'`
echo "   File  $1  is  $SIZE bytes"

mysql -u mythtv -pmythtv mythconverg << EOF
update recorded set filesize = '$SIZE' where basename = '$1';

> Any help with these questions and/or any other constructive suggestions 
> would be appreciated.
In future, run a cron to backup the database to a different drive!


         Please let me know if anything I say offends you.
          I may wish to offend you again in the future.

          Tux says: "Be regular. Eat cron flakes."

More information about the mythtv-users mailing list