I sometimes get myself into real trouble by “optimizing” the fields in my MythTV database. Today I managed to overwrite all my descriptions! My backup was two days old, so I had to figure out how to get as much data back as possible. Well here is how to do it:
Do a backup of your broken database just in case!
Turn of mythbackend (on Ubuntu)
sudo service mythtv-backend stop
Make a copy of your backup to a directory you want to work in.
cp /var/lib/mythtv/recordings4/mythconverg-1264-20110119213749.sql.gz /tmp/
Then unzip the backup.
Now extract only those parts of the database you will need. In my case I needed all fields in the “recorded” table of the database.
cat mythconverg-1264-20110119213749.sql |grep "INSERT INTO \`recorded\`" > out
Now delete all the old entries in the database up to the date/time of your backup.
mysql --default_character_set utf8 -umythtv -p mythconverg -e "DELETE FROM mythconverg.recorded WHERE recorded.starttime < '2011-01-19 21:37:49'"
Lastly import all the old fields to the database.
mysql --default_character_set utf8 -umythtv -p mythconverg < out