User Manual:Periodic Maintenance

From MythTV Official Wiki
Revision as of 18:33, 25 January 2006 by Jdastrup (talk | contribs)

Jump to: navigation, search

Maintaining your MythTV

Your MythTV system can continue to run for weeks, months or even years. Of course, this is unlikely for several reasons. First of all, you can't keep your hands off! Yes, you're a techie and you like to fiddle. Second, hardware can and will fail eventually. Third, power-outages, tornados, alien takeovers and other unfriendly environmental disasters happen. But, if you are interested in keeping your MythTV alive for as long as possible, here's a few suggestions.


Your system is only as good as your backup. What? No Backup? You can't be serious... Well, now is the time to start backing it up. Why? Although you had fun building it and are confident you can rebuild quickly so you don't miss your favorite shows, there are two parts of MythTV that aren't easily replaceable: the database, and your media content (TV recordings, videos, photos, music, etc.)

The database

The database stores a whole lot of stuff you will only miss when it's gone. For example, it keeps a history of every show you've recorded, which is very nice when you don't want to re-record the same show over again. It keeps all the settings of your backends and frontends, it keeps metadata of all your videos (titles, director, parental levels, etc), it keeps all the commercial flaggings, and more.

Probably the easiest way to backup the database is to create a cron job that will dump the data out to a file. Here's a sample script that I put in /etc/cron.daily/

#Dumps the mythconverg database - daily backup
#Keeps the last 7 days
DAY=($(date +%u))
mysqldump -u mythtv -pmythtv mythconverg -c > /mnt/foo/sqldump/$DUMPFILE
exit 0

This will keep a rotating backup of the last 7 days. Notice that the dump location is on a remote server, for added protection.

Backing up to a remote server

Using rsync along with a trusted ssh connection is a way to move backup files from the current machine (your MythTV server) to an alternate machine you may have set up for backup. rsync supports many protocols, including rsh and ssh. This example demonstrates ssh.

# In this example, the source machine is "startrek", and the remote backup server is "stargate".

# Requires ssh tools to make connection to remote host.
# (If you use Debian/Ubuntu, apt-get install keychain).
source /root/.keychain/startrek-sh

# Store knowledge of all currently installed packages. Restore with dpkg --set-selections
# (This is good for Debian/Ubuntu users, along with any other distro based on apt/dpkg pkg mgt).
dpkg --get-selections > /startrek_pkgs.txt

# Backup up all databases. To restore, shutdown the database, move the ib_* files somewhere else,
# startup the database, and the mysql -u root < /mysql_backup.txt.
# (P.S. This is a good place to put in the example listed above!)
mysqldump -A -u root > /mysql_backup.sql

# Push all the files to the backup disk using rsync. This preserves file permissions,
# and also deletes old files on the receiving end not found on the sending end.
# This example pushes everything from the listed folders out to destination "stargate",
# stored in a folder designated for this local machine "startrek". It backs up a wiki site,
# all the kernels built as "deb's", the /home partition, the /etc files, and all the 
# /usr/local/src packages (like MythTV SVN!)
rsync -avq --delete --stats --progress
         /startrek_pkgs.txt /mysql_backup.sql /var/www/mediawiki/images
         /var/www/mediawiki/LocalSettings.php /usr/src/*.deb /home* /usr/local/src

The media

TODO: media backup

OS and software maintenance

I'll start by saying: If it ain't broke, don't fix it! This is more difficult to follow if your MythTV servers other purposes besides Myth. I might add that if you have non-technical people using Myth for their daily TV watching, they will appreciate you keeping your hands off. If you must mess with Myth, please be sure to backup before you do. Expect that fixing one thing will break another.