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 tar cvfp ../tvheadend.tar tvheadend
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 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.
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.