Backup, Replication, Replay and Recovery Planning

Article · 10:00

Backup and restore capabilities by edition, replication where available, replay from a durable event source as the primary recovery strategy, and verification.

Recovery in InfluxDB starts with an uncomfortable fact: your backup options depend heavily on your edition, and in several of them there is no user-facing backup at all. 2.x OSS has influxd backup and restore. 3.x Core and Enterprise have their own mechanisms and the data is already in object storage, which changes the problem. The managed cloud offerings generally do not give you a backup you can take and restore yourself - availability and durability are the provider's responsibility, and point-in-time restore of your own data is not something you control.

That makes replay from a durable event source the primary recovery strategy for telemetry, and it is the honest architectural answer rather than a workaround. The pattern: devices write to a durable log - Kafka, Pulsar, Kinesis, or a queue - the log is the system of record, and a consumer writes to InfluxDB. Three things follow:

  1. InfluxDB becomes a derived store, exactly as the vector databases were in their courses. If you have the log, you can rebuild.
  2. Replay works because writes are idempotent: a write to the same measurement, tag set and timestamp overwrites the fields it names rather than appending. So replaying a window produces the same result as the original write, which is a genuinely useful property and the reason this strategy is sound rather than merely available.
  3. Your RPO is the log's retention and your RTO is the replay rate, both of which you can measure and state - which is a better position than "the provider handles it".

The replay rate is the number that matters. If your ingestion rate is 900,000 points per second and you need to replay a day, that is 78 billion points, and at a replay rate of 900,000 per second that is a day. A replay that takes as long as the outage is not a recovery plan, so the real design question is how far back you can replay in an acceptable time - which usually means replaying the recent window at full rate and accepting the rollups for older data, because the rollups are smaller and may have survived.

Rollups change the recovery picture usefully. If raw data is lost but the hourly and daily rollups survive, you have lost resolution and not history - which for most telemetry is an acceptable degradation and worth designing for deliberately. Keep the rollups in a different bucket or database from raw data, so one being lost does not imply the other.

Replication where available - 2.x OSS has an edge-to-cloud replication feature, and the 3.x editions differ - gives you a second copy. The design points are the familiar ones: it is asynchronous, so there is a lag that is your RPO; and a replica is not a backup, because a destructive write replicates.

Verification must be a correctness check, not a point count. A restored or replayed dataset with the right number of points and wrong values looks exactly like a correct one. The checks that work: the point count per series per window against the source; the aggregate values against the rollups; and the gap check, which finds windows where the expected sample count is missing.

Laboratory exercise 5 - lose it and replay it.

Set up a durable log in front of your ingestion - Kafka or Redpanda in Docker is enough - and make the log the system of record with a consumer writing to InfluxDB.

Establish the replay capability first. Delete a day of data, replay it from the log, and time it. State that as your RTO and the log's retention as your RPO.

Demonstrate write idempotency: replay the same window twice and show the point count and the aggregate values unchanged. That property is what makes the whole strategy work and it is worth seeing.

Take a backup if your edition supports it, perform a destructive change, and restore. Record RPO and RTO for that path and compare with the replay.

Then the capacity question: measure your replay rate and calculate how far back you can replay within your target RTO. If the answer is less than your retention, say so and design the degradation - which rollups you preserve and what resolution you accept losing.

Demonstrate the rollup survival strategy: destroy the raw bucket while keeping the rollup buckets, and show the dashboards still working at reduced resolution.

Configure replication if your edition supports it, measure the lag, and then demonstrate that a destructive write replicates - because that is the thing people assume a replica protects them from.

Finally, write the verification: point counts per series per window against the log, aggregates against the rollups, and a gap check.

Deliverable: the log-fronted architecture, the replay with a measured RTO and a stated RPO, the idempotency demonstration, the backup path if available, the replay-rate capacity calculation with its degradation design, the rollup survival demonstration, the replication lag and the destructive-write demonstration, and the three verification queries.

-- ==================================================================
-- *** THE UNCOMFORTABLE FACT FIRST: YOUR BACKUP OPTIONS DEPEND
-- *** HEAVILY ON YOUR EDITION, AND IN SEVERAL THERE IS NO
-- *** USER-FACING BACKUP AT ALL. ***
-- ==================================================================
--   2.x OSS:
--     influxd backup -portable /backups/$(date +%F)
--     influxd restore -portable -db telemetry /backups/2026-11-30
--     influx backup /backups/full --org acme --token $TOKEN
--
--   3.x Core / Enterprise: its own mechanisms, AND THE DATA IS
--     ALREADY IN OBJECT STORAGE - which changes the problem into one
--     of snapshotting a bucket and the catalogue together.
--
--   MANAGED CLOUD: generally *** NO BACKUP YOU CAN TAKE AND RESTORE
--     YOURSELF. *** Availability and durability are the provider's;
--     point-in-time restore of YOUR OWN data is NOT something you
--     control. Check your edition and WRITE DOWN WHAT YOU ACTUALLY
--     HAVE before you need it.

-- ==================================================================
-- *** SO REPLAY FROM A DURABLE EVENT SOURCE IS THE PRIMARY RECOVERY
-- *** STRATEGY FOR TELEMETRY. *** And it is the honest architectural
-- *** answer rather than a workaround.
-- ==================================================================
--   devices -> *** KAFKA / Pulsar / Kinesis (the SYSTEM OF RECORD) ***
--           -> consumer -> InfluxDB (a DERIVED store)
--           -> consumer -> object storage (cold archive)
--
-- THREE THINGS FOLLOW:
--
-- (1) *** INFLUXDB BECOMES A DERIVED STORE ***, exactly as the
--     vector databases were in their courses. If you have the log,
--     you can rebuild.
--
-- (2) *** REPLAY WORKS BECAUSE WRITES ARE IDEMPOTENT. *** A write to
--     the same measurement + tag set + timestamp *** OVERWRITES ***
--     the fields it names rather than appending:
--       machine_telemetry,machine=press-07 value=74.3 1764500460000000000
--       machine_telemetry,machine=press-07 value=74.3 1764500460000000000
--     -> ONE point, not two. DEMONSTRATE IT:
SELECT COUNT(*) FROM machine_telemetry
WHERE machine = 'press-07' AND time = '2026-11-30T14:01:00Z';
--     -> 1, after replaying the window twice.
--     *** THAT PROPERTY IS WHAT MAKES THE WHOLE STRATEGY SOUND
--     *** RATHER THAN MERELY AVAILABLE ***, and it is worth seeing
--     once with your own eyes.
--
--     (The caveat: a replay that omits a field leaves the OLD value
--      for that field in place, because the overwrite is per field.
--      Replay complete points.)
--
-- (3) *** YOUR RPO IS THE LOG'S RETENTION AND YOUR RTO IS THE REPLAY
--     *** RATE *** - both of which you can MEASURE AND STATE, which
--     is a better position than "the provider handles it".

-- ==================================================================
-- *** THE REPLAY RATE IS THE NUMBER THAT MATTERS. ***
-- ==================================================================
--   ingestion rate               900,000 points/s
--   a day of data             77,760,000,000 points
--   replay at full rate        ~24 hours
--
-- *** A REPLAY THAT TAKES AS LONG AS THE OUTAGE IS NOT A RECOVERY
-- *** PLAN. *** So the real design question is HOW FAR BACK YOU CAN
-- REPLAY IN AN ACCEPTABLE TIME:
--
--   measured replay rate            ___ points/s
--   target RTO                      ___ hours
--   -> replayable window            ___ hours of data
--   -> and if that is LESS THAN YOUR RETENTION, SAY SO AND DESIGN
--      THE DEGRADATION:
--        replay the RECENT window at full resolution
--        accept the ROLLUPS for older data
--        state the resolution lost, per time range

-- ==================================================================
-- *** ROLLUPS CHANGE THE RECOVERY PICTURE USEFULLY. ***
-- ==================================================================
-- If RAW data is lost but the HOURLY and DAILY rollups survive, you
-- have lost RESOLUTION AND NOT HISTORY - which for most telemetry is
-- an ACCEPTABLE DEGRADATION and worth designing for deliberately.
--
-- *** SO KEEP THE ROLLUPS IN A DIFFERENT BUCKET OR DATABASE FROM RAW
-- *** DATA, so one being lost does not imply the other: ***
--   2.x:  telemetry (7d) / telemetry_1m (90d) / telemetry_1h (2y)
--   3.x:  separate databases, or separate tables with their own
--         retention where the edition supports it
--
-- DEMONSTRATE IT: destroy the raw bucket, keep the rollups, and show
-- the dashboards still working at reduced resolution. That
-- demonstration is what justifies the separation in the design
-- document.

-- ==================================================================
-- REPLICATION, where available.
-- ==================================================================
--   2.x OSS edge-to-cloud:
--     influx remote create --name cloud --remote-url https://... \
--       --remote-api-token $CLOUD_TOKEN --remote-org-id $ORG
--     influx replication create --name telemetry-repl \
--       --remote-id $REMOTE --local-bucket-id $LOCAL \
--       --remote-bucket telemetry --max-queue-size 1073741824
--     influx replication list      -- the QUEUE SIZE is your lag
--
--   3.x editions differ - check yours.
--
-- THE FAMILIAR DESIGN POINTS:
--   * it is ASYNCHRONOUS, so there is a LAG THAT IS YOUR RPO.
--     Measure it; the queue depth is the signal.
--   * *** A REPLICA IS NOT A BACKUP, BECAUSE A DESTRUCTIVE WRITE
--     *** REPLICATES. *** Demonstrate it: delete a measurement
--     locally and watch it disappear remotely. That is the thing
--     people assume a replica protects them from, and it does not.

-- ==================================================================
-- *** VERIFICATION MUST BE A CORRECTNESS CHECK, NOT A POINT
-- *** COUNT. *** A restored dataset with the right number of points
-- *** and wrong values looks exactly like a correct one.
-- ==================================================================
-- (1) POINT COUNT PER SERIES PER WINDOW, against the source:
SELECT date_bin(INTERVAL '1 hour', time) AS hour,
       site, machine, sensor, COUNT(*) AS points
FROM machine_telemetry
WHERE time >= '2026-11-29T00:00:00Z' AND time < '2026-11-30T00:00:00Z'
GROUP BY 1, site, machine, sensor
ORDER BY hour, machine;
--   compare with the log's offsets for the same window.

-- (2) AGGREGATES AGAINST THE ROLLUPS - which catches wrong VALUES,
--     not just missing rows:
SELECT r.time, r.machine, r.mean_value AS rollup_mean,
       x.mean AS raw_mean, ABS(r.mean_value - x.mean) AS drift
FROM machine_telemetry_1h r
JOIN (SELECT date_bin(INTERVAL '1 hour', time) AS time, machine,
             AVG(value) AS mean
      FROM machine_telemetry
      WHERE time >= '2026-11-29T00:00:00Z'
        AND time <  '2026-11-30T00:00:00Z'
      GROUP BY 1, machine) x
  ON x.time = r.time AND x.machine = r.machine
WHERE ABS(r.mean_value - x.mean) > 0.001;
--   Expected: no rows. *** THIS IS THE CHECK THAT CATCHES A REPLAY
--   *** THAT WROTE THE WRONG VALUES. ***

-- (3) THE GAP CHECK - windows where the expected sample count is
--     missing:
SELECT b.bucket, COALESCE(c.points, 0) AS points
FROM generate_series('2026-11-29T00:00:00Z'::timestamp,
                     '2026-11-30T00:00:00Z'::timestamp,
                     INTERVAL '1 hour') AS b(bucket)
LEFT JOIN (
  SELECT date_bin(INTERVAL '1 hour', time) AS bucket, COUNT(*) AS points
  FROM machine_telemetry
  WHERE machine = 'press-07' AND sensor = 'bearing_temp'
    AND time >= '2026-11-29T00:00:00Z' AND time < '2026-11-30T00:00:00Z'
  GROUP BY 1
) c ON c.bucket = b.bucket
WHERE COALESCE(c.points, 0) < 3400      -- 3,600 expected, allow slack
ORDER BY b.bucket;
--   Expected: only the windows you know had an outage.
--
-- "The database is accepting writes" is NOT verification.

Discussion

No questions on this topic yet. Sign in to ask the first one.