How-to
Move an Ignition historian database with pre-copied partitions
Short answer
Yes, the drop-and-restore plan works, but the safer route pre-copies the whole database to the new server and moves only the sqlth_* metadata and the partitions still being written at cutover. Store-and-forward buffers history writes through the switch, so downtime is a delta copy and the history never has a hole.
On this page
Yes, the plan works: drop the closed sqlt_data_1_yyyymmdd tables on the running system, cut over the reduced database, then restore those tables and their sqlth_partitions rows on the new server, and the history reads whole again. It is simply the long way round. Pre-copying the full database to the new server and moving only the delta at cutover gives you the same short window with no hole in production trends and no hand-inserted index rows. Neither path is a vendor-documented procedure, so rehearse it once against a copy of the database before you run it where it counts.
How the historian resolves a query #
sqlth_partitions is the index. Ignition's database table reference lists it as holding the time range each sqlt_data table covers; for any trend or history query the gateway reads that index first, picks the partition tables whose ranges intersect the requested window, and only then queries those tables. Two failure modes fall out of that design:
| Index state | What you see | What the gateway does |
|---|---|---|
| Pointer row present, table missing | Trend error or empty pens for that range | Queries a table that does not exist; the database error lands in the gateway log |
| Table present, pointer row missing | Silent gap, no error | Never learns the table exists |
| Both present, tag IDs found in the metadata table | Continuous line | Normal operation |
A blank trend with no error usually means the rows are in the table and the index row is gone. The t_stamp column inside the partitions is what the query walks next, and querying Ignition tag historian t_stamp and sqlt_data partitions covers that layer in detail.
Method A: drop, cut over, restore later #
The original plan, in order:
- Take the full copy of the historian database to the new server now. That copy is the archive the closed partitions come back from.
- On the live database, drop the closed-year
sqlt_data_1_yyyymmddtables and delete theirsqlth_partitionsrows. From that moment, every trend on the live system loses that range. - At cutover, copy the reduced database across, point the gateway at the new server, and bring history back up. The window is short because the reduced database is small.
- Restore the dropped tables from the first copy into the new database.
- Re-insert their
sqlth_partitionsrows from that same copy, and copy them rather than retype: the table-name, driver and time-range values must be exactly what the archive holds. - Read the history provider's data pruning setting before those rows go in: pruning enabled with a retention shorter than the age of the restored data deletes the restored partitions again on the next maintenance pass.
One check belongs to this method alone: partition tables address tags by numeric ID, and every ID must exist in the tag metadata table of the cutover copy. Select the distinct IDs each restored table uses and join them against that metadata; an ID with no matching row plots nowhere.
Method B: pre-copy the full database, move the delta #
Nothing on the live system changes before cutover.
Stage, days ahead #
- Install the database engine on the new machine and restore the full first copy. MariaDB works as a drop-in for MySQL in this role; if you change engine or major version, update the gateway's JDBC driver before cutover, not after.
- Record the row count of every closed-partition table on the old server. You compare against this list at cutover.
- On the gateway, change the database connection URL from an IP address to a DNS name, and point the name at the old server for now. Keep the connection name unchanged so history providers, transaction groups and bindings never notice the move.
- Set the store-and-forward buffer to hold the whole planned window, then confirm the connection is healthy through the DNS name and full-history trends still render.
At cutover #
- Build the delta list on the live database:
SELECT table_name
FROM information_schema.tables
WHERE table_schema = DATABASE()
AND (table_name LIKE 'sqlth\_%'
OR table_name LIKE 'sqlt\_data\_%\_2025%');
The digit after sqlt_data_ identifies the driver connection that wrote the table, so keep every number the query returns if several gateways share this database. Re-run the row-count comparison and add any closed table whose count moved: late store-and-forward flushes write into closed partitions, and the staged copy misses exactly those rows — the gap what Ignition historian failover leaves behind in the second database describes. A scripted backfill can rewrite closed partitions outright, the way why storeDataPoints backfill drops history partitions shows.
- Stop history writes to the old database: disable the connection, or stop the old database service. The gateway buffers new samples in store-and-forward.
- Dump the delta tables with
mysqldump --single-transactionand the explicit table list, then restore the dump into the new database. Overwriting the staged copies of those tables is intended: the live tables are a superset of the staged ones. - Point the DNS name at the new server, and restart the connection if the gateway cached the old address.
- Re-enable the connection and watch store-and-forward drain to zero. The buffered rows land as a backfill once the connection is healthy — the same sequence MQTT store and forward backfill after a connection outage walks through.
A worked cutover budget #
Illustrative numbers, so you can size your own move. Take a 380 GB historian database: 352 GB in closed partitions, 27.5 GB in the partitions of the year being written, and about 40 MB of sqlth_* metadata. Take a copy path that sustains 70 MB/s.
The stage copy runs days early at zero downtime: 380 GB × 1,024 = 389,120 MB, and 389,120 MB ÷ 70 MB/s ≈ 5,559 s ≈ 93 minutes.
The cutover delta is the open year plus the metadata: 27.5 GB × 1,024 = 28,160 MB, plus 40 MB ≈ 28,200 MB, and 28,200 MB ÷ 70 MB/s ≈ 403 s ≈ 7 minutes each way for dump and restore. With the connection restart and the drain, plan a 15-minute write stop.
Method A moves the same 28 GB at cutover, so its window is the same 15 minutes — the drop buys no downtime. It then owes the closed-partition restore: 352 GB × 1,024 = 360,448 MB ÷ 70 MB/s ≈ 5,149 s ≈ 86 minutes of copying with the closed years blank on the new system, plus the hand-inserted index rows.
Size the buffer against the same window: at 1,000 history rows per second, 15 minutes is 1,000 rows/s × 900 s = 900,000 buffered rows, and the buffer setting must cover that before the window opens.
The checks that prove the history is whole #
Run this against the new database after the move:
-- pname stands in for the column DESCRIBE sqlth_partitions
-- shows as holding each partition's table name; use that column
SELECT p.pname
FROM sqlth_partitions AS p
LEFT JOIN information_schema.tables AS t
ON t.table_name = p.pname
AND t.table_schema = DATABASE()
WHERE t.table_name IS NULL;
Zero rows is a pass; every row returned names a partition the index expects but the copies missed. Under Method A, also run the tag-ID join from that method and expect zero unmatched IDs. Then open a trend with pens from more than one provider, spanning the boundary between the closed year and the open one: the line must be continuous, with no step or blank segment at the partition edge. Zoom last on the cutover minute itself: the pens run straight through the write stop once store-and-forward has drained.
The decision #
Use Method B. Both methods put the same 28 GB on the wire at cutover, so dropping the closed partitions shortens nothing; it only opens a hole in production trends and puts a human between the index and the archive. Keep Method A for the one case it fits: the new server cannot hold the full database until after cutover. Then run the restore immediately at switch-over rather than later, and treat the index-row insert as part of the cutover itself.
| Method A | Method B | |
|---|---|---|
| Live database before cutover | Closed partitions dropped, index rows deleted | Untouched |
| History after cutover | Open range only, until the restore lands | Complete |
| Post-cutover work | Restore 352 GB, re-insert index rows, verify pruning and tag IDs | Verification only |
Questions asked
What happens to the delta query if the cutover slips into a new year?
The pattern only matches the year it names, so a January cutover would skip the partitions being written. Change the year in the LIKE pattern, and if the migration window crosses the year boundary, match both years with an OR. Closed years touched by late flushes are still caught by the row-count comparison.
How do I make a history provider see restored partitions without restarting the gateway?
Disable and re-enable the database connection the provider uses. The provider re-reads its partition list when the connection comes back, which is enough after index rows are inserted. A full gateway restart also works but takes everything else on that gateway down with it for the length of the startup.
Can I verify the move with queries instead of watching trends?
Yes. While history writes are still stopped, count the rows in every sqlt_data and sqlth_ table on the old server and on the new one. With no writer active the counts must match table for table, and any mismatch names the table the delta missed. Trends across the closed-year boundary remain the final visual check.
How do I roll back if the new database misbehaves after cutover?
Point the DNS name back at the old server and restart the connection. Method B leaves the old database untouched, so history resumes from it at once. The only rows on the wrong side are the ones written to the new server during the trial, so keep that window short or copy those partition tables back before the final switch.