HowTo Backup Your MythTV Installation

Installing MythTV can be quite a hassle. Re-installing after a disk crash half an hour before that vital episode of Coronation Street is due to install is enough to give anyone PTMTVD (Post Traumatic MythTV disorder). This article describes a strategy for backing up your MythTV system. Note this article does *not* include backing up your video files.

Preparing the Base System.

The overall strategy is to create a system where the operating system and database are on a relatively small partition of around 15 GByte and the recordings are on their own partition. This makes it much easier to make a backup of your MythTV installation onto a usb hard drive, or even DVD’s. You will need a separate backup method for your recordings. I only backup recordings I really care about by copying them onto network storage, which has mirrored hard drives. I then mount the storage device onto my MythTV box via nfs.

Using this system I can rcover from a hard drive failure on my MythTV system in less than an hour.

Partitioning Your Hard Disk.

I usually create three partitions:

  • First partition of around 15 GByte, which will hold your Linux distro and the MythTV installation, but not the video files (/dev/sda1).
  • Second partition of around 1 GByte. This is used as a swap partition (/dev/sda2).
  • Third partition - the rest of the disk. This is used to store all your video files (/dev/sda3).

The actual partition names will vary according to your system configuration.

Install your distro of choice onto a small partition. I usually create a primary partition of around 15 GByte.

Now install MythTV as you would do normally.

Configuring MythTV.

By default MythTV will store your recordings in /var/lib/mythtv, which if you have followed my partitioning suggestion will be on your first partition. If you followed the partitioning suggestion above, you need to alter this to store recordings on th third partition (/dev/sda3).

  • Make sure that /dev/sda3 gets mounted at boot time.
  • Create a directory to mount the partition and make sure its owned by mythtv:
sudo mkdir /mnt/sda3
sudo chown mythtv.users /mnt/sda3
  • Edit fstab and add a line to mount /dev/sda3:
sudo vim /etc/fstab

# /dev/sda3
UUID=a13d6e1d-bc06-433a-9209-ffc0dfb622f9 /mnt/sda3 ext3 defaults 0 0
  • Either reboot, or mount /dev/sda manually:
sudo mount -a
  • Start mythtv-setup and edit the recordings directory to point to /mnt/sda3.

Now your recordings are stored on a separate partition to the operating system and MythTV.

Backing Up The Root Partition.

If you followed the partitioning guide above the operating system and MythTV will be on /dev/sda1, which is 15 GByte. Most of this will be free space, so it should be possible to back up the whole of /dev/sda1 into a relatively small compressed file. There are a number of ways of creating a backup of a partition. The method I use is to boot the computer from a Knoppix CD and use partimage to create the backup onto an external usb hard drive.

Backing Up the Database.

It’s important to take regular backups of the database (mythconverg). All the information about your setup and recordings is held there and you would have a very hard time recreating it from scratch. It’s also important to have several backups, as often it can be a few days before you notice something is wrong and keeping just one or two backups mat result in your backup containing a corrupted database.

I use a script called automysqlbackup . The following is a list of automysqlbackup’s features taken from its web site:

  • Backup multiple MySQL databases with one script. (Now able to backup ALL databases on a server easily. no longer need to specify each database seperately)
  • Backup all databases to a single backup file or to a seperate directory and file for each database.
  • Automatically compress the backup files to save disk space using either gzip or bzip2 compression.
  • Can backup remote MySQL servers to a central server.
  • Runs automatically using cron or can be run manually.
  • Can e-mail the backup log to any specified e-mail address instead of “root”. (Great for hosted websites and databases).
  • Can email the compressed database backup files to the specified email address.
  • Can specify maximun size backup to email.
  • Can be set to run PRE and POST backup commands.
  • Choose which day of the week to run weekly backups.

I run the script as a daily cron job and copy the backup directory to another computer on my network. It’s important that you make a copy of the backup to another computer. If you don’t and the hard disk in your MythTV dies, you will have lost your database backup.

Restoring MythTV and the Database.

In the event of a hard drive failure, restoring is simple. You must create partitions on your new hard drive at least as big as the ones on the original drive. It doesn’t matter if you make them larger. You can use any live Linux CD, such as Ubuntu to create the partitions. Once you have created the partitions on the new hard disk, just fire up partimage and use it to restore the back up image of your root partition (/dev/sda1 in my example).

Now you need to restore the most recent backup of the database from automysqlbackup. The backups are stored in compressed format by default, so you need to uncompress it first:

gunzip mythconverg_2007-12-16_09h00m.Sunday.sql.gz

You can then restore the backup to the mythconverg database:

mysql -u mythtv -ppassword < mythconverg_2007-12-16_09h00m.Sunday.sql

Note that there are no spaces between -p and your password (mythtv by default).


11 Comments

tom?06 November 2008, 17:21

Hi just came across your site which looks really handy (I was looking for something to convert my radio recordings to mp3 so will give your script a go). I backup using partimage with the same kind of disk partitions to you - I stick an image in sda3 but also copy it off to another machine. However I run VGA→SCART PAL, which means if I run off a boot disk, I don’t get any display - do you know of a boot disk that has telnetd/sshd enabled on startup? Or do you think I’ll have to roll my own? Ta

Larry?21 February 2009, 07:58

Hi, I found this simple and good howto when googling mythtv backupping solutions :)

I’d like to add one possibility: You can use LVM for volumes so you can resize them easily without rebooting and even online if filesystem supports it. Also LVM supports snapshots, which are very quick way to backup one filesystem.

With LVM it wouldn’t be big problem to make fourth partition for MySQL databases, because you can resize volumes if one volume is too small.

When MySQL databases are on own partition then it is possible to snapshost all other things easily with daily cron job at the same time as MySQL dumps are made. Then you have always up to date operating system and database (and recordings if them are decided to backed up) backups from same day.

There could be one big disk for snapshots. Second computer could then read that disk and compress backups to be stored outside of MythTV backend machine. So MythTV backend doesn’t need to use power for that kind of operating.

I hope somebody founds this useful information.

mario?05 March 2009, 05:25http://ut.grt.com

WlhjfI h1! nice site! oxyutelno

3a39f35f87<a href= http://forums.slimdevices.com/member.php?u=26889 >ultram addiction</a>

abdulla?17 March 2009, 22:44http://trustedsitelist.com

maxmud?17 March 2009, 22:45http://trustedsitelist.com

Maxx35?10 October 2009, 21:54link

I believe that the situation would improve drastically if you were able to show that the technology works realiably and suffiently fast for simple use cases, most importantly file search. ,

KGjhiYCfwjaYOXyK?12 October 2009, 19:27

doors.txt;10;15

Barbara84?13 October 2009, 09:23link

I know, reading this from thousands of miles away, she’s actually a lovely person. ,

Barbara55?22 October 2009, 09:35link

Many health insurance plans ask patients to get a second opinion before they have certain operations that are not for an emergency. ,

No_limits54?23 October 2009, 09:13link

Signing off,PrateekOkay Here I have a brain teaser for all of you:Two batsmen are on 94 not out each. ,


Add Comment 
Sign as Author 
Website 
Enter code 764


Back to MythTV.BackupHome Page