Skip to content

Backup and Restore

Outcome: a complete backup made with the built-in tool — and then proved, by restoring it into an empty server and counting the data that came back. The proof includes the lab's own half-finished restore and its rescue. Transcripts: influxdb-lab/transcripts/t07-backup.txt and t08-restore.txt.

The backup: one command, five files

influx backup backup-2026-11-01
INFO: Downloading metadata snapshot
INFO: Backing up TSM for shard 1
INFO: Backing up TSM for shard 3
INFO: Backing up TSM for shard 2

The backup is a folder, and its contents are chapter 2's moving parts made visible: a manifest (the inventory), the metadata snapshot as .bolt.gz and .sqlite.gz (users, organisations, buckets, tokens, tasks), and one .tar.gz per shard — the time-sliced files the measurements themselves live in. The whole lab instance — an hour of weather, three buckets, two tokens, a task — backed up to 28 KB. Backups are taken from the running server and need the operator token; the CLI's active config already holds it.

A backup is a folder of ordinary files, so it inherits ordinary file rules: it contains everything, tokens included, and deserves encrypted storage and the same care as the config file from chapter 3.

The restore: where the lab earned its keep

The test that matters is not the backup but the restore, so the lab built the disaster honestly: it stopped the server, set the data folder aside untouched, and started a fresh, empty influxd on the same port. On that virgin instance the lab's CLI config — its org, its operator token — meant nothing:

Error: failed to list buckets: 401 Unauthorized: unauthorized access

First trap: influx restore demands an operator token of the instance receiving the restore, and a fresh instance has no users at all. The way in is to run influx setup on the fresh instance — a throwaway admin, a scratch organisation — purely to mint a local operator token, and restore with that.

Second trap, the instructive one: the restore with the throwaway token restored the metadata snapshot — and then died:

INFO: Restoring KV snapshot
INFO: Restoring SQL snapshot
Error: failed to restore SQL snapshot: 401 Unauthorized: unauthorized access

Half a restore is a strange country. The KV stage had replaced the fresh instance's identity with the backup's — organisations, buckets and the original tokens — so the throwaway token the restore was running under had ceased to exist mid-restore, and the next stage refused it. The instance now listed the original buckets under the original config (bucket ls worked again) but held no data at all: the count query of chapter 4 returned empty, exit 0, no complaint. Buckets restored, measurements not — a state that looks healthy until somebody asks a question.

The rescue follows from the diagnosis: once the backup's identity is in place, the backup's own operator token is the instance's right token. Re-running the same full restore under the original config completed every stage:

INFO: Restoring TSM snapshot for shard 1
INFO: Restoring TSM snapshot for shard 3
exit=0

And the count, run a third time, is the chapter's receipt: garden-1 6 and 6, rooftop-1 6 and 6, http-1 1 and 1 — every point that existed at backup time, present in a server that had been empty an hour before.

Working rules

  • Back up with the built-in tool, on a schedule, and copy the folder off the machine — a backup beside its database is a souvenir, not a backup.
  • Practise the restore before you need it, and remember the order of operations: fresh instance, throwaway setup, restore with the fresh token, restore again with the backup's token when the first stops at the SQL stage. Better still, keep the backup's operator token in your password manager, labelled — the restore is the day you will want it.
  • Verify by counting, not by listing. A restore can return your buckets and none of your data; only a query knows the difference.
  • The restore is destructive and total: --full replaces the receiving instance's identity and data with the backup's. The lab's original data folder was set aside before any of this began, untouched, and that habit is the chapter's last word.