Tvheadend does include it's own way to upgrade the databases inside of the settings folder etc. However the way tvheadend settings are stored is not simple so it may encounter unforseen problems whilst doing that.
Here is what i do:
* Take a screenshot of my DVR entries, and DVR "AutoRec" entries tabs.
* And of any other user settings pages you think you may forget.
* Backup the config folder (as suggested by Anders ^^).
* Create a basic 'pre-scan' skeleton config. This cannot include any channelsm muxes or services. As the GUIDs of those things changes between installations and is no consistent.
* Delete config folder.
* Replace with pre-scan skeleton folder.
That can include your
user accounts files
adapters list (before 1st scan)
networks added BEFORE 1st scan (i.e. just the network setting itself for the adapters ^^ to know which network they belong to. NOT any scanned GUID services insice the netowrks/ subfolder)
dvr profiles
bouquests (if DVB-S)
* other general / global settings
Uninstall Tvheadend 3.4
Install Tvheadend 4.0.x
(via tvheadend apt sources, just like you said)
* Run tvheadend again for 1st time.
* If your skeleton config folder is correct, it should restore your user accounts and adapters, etc.
* Proceed to let tvheaedend perform it's 1st scan. Preferably it will auto-populate the channels map via bouquest or DVB-T.
* Then re-enter manually your DVR programme entries in the DVR tab (which shows are scheduled to record).
It sounds complex but avoids any problems with a messed up config. Because you always start with a clean config. Have already automated this proceedure as much as possible with docker as the public docker image "dreamcat4/tvheadend.config".
The only thing is it can't do is:
a) Keep your DVR entries. Because the GUID for the channel (of a new scan) always changes.
b) Keep custom / manual channel mappings (which are not resotred by the automatic bouquets system). Because the GUID of the underlying service that the channel points to always changes between scans.
To solve that would need some hassles of a custom script to match regex expressions against the channel names and service names, then to reconstruct via tvheadend API (add DVR entry X,Y,Z from import, add Channel --> Service GUID ABCD-xxxx- from import list of manual channel mappings).