Transferring Tag Historian data to a new server

On multiple occasions I have needed to integrate past tag history data into a new Ignition install after the new system has started historizing tag data. (New database and new Ignition but maintaining all the tag history data from the earlier system.) It tends to get messy with the new system generating id’s that already existed in the prior system. Knowing that we will continue to face this issue of migrating from an existing system to a new system I’m hoping to learn a smoother way to get the job done such as taking steps prior to turning on the history on the new system so that we can just migrate the past data.

My first thought is to migrate some or all of the metadata tables (sqlth_te, sqlth_partitions, and possibly sqlth_scinfo, sqlth_sce, sqlth_drv, and sqlth_annotations) to the new database before we start historizing tags on the new system in hopes of avoiding any duplicate tagids relative to the prior data. Does anyone know if that would work or if there are other steps that would help when migrating old data onto a new system?

My guess is that it should work, as long as you restart the historian provider before enabling the historization on your new tags, to let the historian rebuild its cache.
If you don't, data coming to the tag will not match anything in the cache, and a new entry will be created in sqlth_te.

I'm not entirely sure that it will just work, but the good news is that it's easy to test.

Keep in mind that the gateway's internal name is part of the metadata, and a new server that will continue history needs to have the same name. This happens automatically with gateway backups, but is often overlooked if standing up a new gateway while the old continues to run.