How to move Tvheadend’s settings from one system to another, or preserve them during a full reinstallation

If you have Tvheadend currently running on an existing system, and you decide to build a new system OR do a full reformat and reinstall on your current system (maybe because you want to upgrade the operating system and/or Tvheadend itself), you may have wondered if there is a way to move Tvheadend’s settings from one system to another, or to reinstall them on a system after a full update, even one that involves reformatting the hard drive. While there is no officially supported method, there have been several posts in the Tvheadend forum recently stating that people have had success in doing this by simply copying over the /home/hts/.hts/tvheadend directory from one system to another. However it’s not quite that simple, because you want to preserve permissions and ownership of the files, and there are a few other steps. As best I can determine, here is the full procedure (yes, I realize there is some redundancy in the use of sudo here). You should probably read the entire post before actually doing anything, and make sure you understand the entire process.

On the existing system, enter the following commands:

sudo service tvheadend stop
sudo -s
cd /home/hts/.hts
sudo tar cvfp ../tvheadend.tar tvheadend
cd /home/hts/

At this point you need to move tvheadend.tar file to a different system if you plan on reformatting the drive, or to the new system if you’re creating an entirely new setup after you have installed Tvheadend as described below. I would also urge you to copy any recordings you wish to keep, and any programs/scripts you may run outside of Tvheadend (for example, scripts and data to provide guide information to Tvheadend). You can use a Linux tool such as scp for this process (for example, sudo scp tvheadend.tar root@ip:~/) or if you have a way to transfer files via nfs, samba, ftp, sftp, etc. it doesn’t matter, just so long as you can move the tvheadend.tar file and any other files you want to save to a safe place.

On the new system, install your operating system and the driver(s) for your tuner card(s)/device(s), if any. Then install Tvheadend using one of the methods shown on the Download page. After you have done that, check to make sure that Tvheadend can find your tuners (in the TV adapters tab) – if it can’t then you need to figure out why before proceeding. Next, copy back/over all the files you saved in the previous step, putting them in the exact same directories they were in on the previous system (this is especially important if you want Tvheadend to find any recordings you saved). Then enter the following commands on the new system:

sudo service tvheadend stop
sudo -s
cd /home/hts/.hts
sudo mv tvheadend tvheadend-backup
tar xvfp ~/tvheadend.tar

Now if you reboot (or restart Tvheadend) you should find that your previous configuration is restored, except that it is possible that your tuner(s) will not be linked to any network(s). So go back to the TV adapters tab and make sure that each tuner is enabled and that it is linked to the correct network. Also, if you did not copy over the recordings from your previous system (or failed to put them back in the exact same spot in the directory tree), they will show up under the “Failed Recordings” tab in the Tvheadend web interface, so you can go ahead and delete those. Also, check the “Recording System Path” and the Timeshift “Storage Path” (under the Recording tab) to make sure that they are correct and that you have actually created directories with those names, and that they have the correct permissions and ownership.

If for some reason it does not work and you want to reconfigure Tvheadend from scratch, stop the Tvheadend service, delete the /home/hts/.hts/tvheadend directory, and rename the /home/hts/.hts/tvheadend-backup directory back to just tvheadend. Then reboot, or restart Tvheadend.

EDIT (August 2017): Note that if you are moving to Tvheadend version 4.2 or later from a pre-4.2 version, you may find that everything will work fine until you try to add a new channel to an existing mux, by rescanning the mux. It seems Tvheadend may find the new service, and allow you to map it as a new channel, but when you go to watch it you will get “No input source available for subscription” errors. The problem is that in 4.2 there are some new mux settings that you can only see if you set the View level to Expert. They are the checkboxes for “Accept zero value for TSID:” and “EIT – skip TSID check:”, and by default both are unchecked. But here in North America, providers often use invalid transport stream IDs. So, you probably need to check the boxes for both of those, and again, you will not even see those settings unless you set the view level to Expert. If you don’t do this, Tvheadend may not scan in any or all of the available services on the mux, but even if it does find and add a new service, you might get errors when you attempt to view a channel that you have mapped from the service.

New checkboxes in Tvheadend 4.2

If that doesn’t resolve the problem, you may need to delete the existing mux and any associated services and channels, and then re-add that mux, and then rescan the mux and re-add your channels. But maybe you fear that if you delete your existing channels, Tvheadend won’t rescan them. So if you want to assure yourself that Tvheadend can rescan the mux before you delete the existing one, create a temporary “test” network, temporarily link it to the tuner associated with the correct satellite dish and LNB, and then create a new temporary mux under that. That will allow you to see if Tvheadend can find the services in the mux before you delete your existing mux, services, and channels. If it works, you can delete the test network and temporary mux, as well as the existing mux and associated services and channels, and then recreate the mux using the correct network. (End of edit).

Once you are sure that everything is working the way you want, you can delete the tvheadend.tar file and the tvheadend-backup directory. However, it might not be a bad idea to take a “snapshot” of the /home/hts/.hts/tvheadend directory from time to time, and save it to a different system or at least a different hard drive, so you have a way to go back to working settings if everything falls apart or you make some major blunder.

When creating a new system, keep in mind that if you were using ffmpeg for any purpose on your previous system, you should make sure it is properly installed on the new one, and that if it’s not in the same place in the directory tree that you adjust any links accordingly. Also make sure any programs that provide guide data to Tvheadend are working correctly (you may need to check the permissions and ownership), and if you had any scheduled cron jobs, make sure you recreate those.

Some of the information in this post was derived from posts by Mark Clarkstone in an obscure thread in the Tvheadend forum.

Advertisements

One thought on “How to move Tvheadend’s settings from one system to another, or preserve them during a full reinstallation

  1. Pingback: Install TVHeadend in a Proxmox LXC Container running Ubuntu 16.04 – Gav's Tech Blog

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s