IMD SolutionComputing LibraryShop main store

How-to

InfluxDB annotated CSV migration between two Docker hosts

Edge computing and IIoT Published 7 min read

Short answer

Export only what the new host needs as annotated CSV with influx query --raw and a _measurement filter: one reported 30-day set fell from 1.3 GB to 32 MB, and even that file had to be split because the 2 GB VM died importing it whole. Work in fixed windows of about 1 MB, upload per bucket, validate counts and timestamps, and use backup and restore when the whole history must move.

On this page
  1. Which path moves the data: annotated CSV or backup and restore?
  2. How large can one CSV import be on a 2 GB VM?
  3. How do you export one measurement to annotated CSV?
  4. Where do you cut a large annotated CSV safely?
  5. What is the full import procedure into the new bucket?
  6. What do you verify after each batch lands?
  7. Questions asked

Moving InfluxDB history from one Docker host to another fails when the whole bucket travels as one file. Export only the measurements and time windows the new host needs as annotated CSV, split the work into fixed windows, upload bucket by bucket, and validate counts and timestamps after every batch. In one reported migration, a _measurement filter cut a 30-day export from 1.3 GB to 32 MB, and even that file was too much for a 2 GB VM importing it whole. The steps below cover the selective CSV path end to end; for a complete instance, use backup and restore instead.

Which path moves the data: annotated CSV or backup and restore? #

Choose the CSV path when you are moving selected measurements into new or renamed buckets, and choose backup and restore when the whole instance must arrive intact: the reported migration needed specific data in newly named buckets, which is exactly the CSV case.

The two paths carry different things. Annotated CSV moves points only: the annotation rows tell the destination how each column becomes line protocol, so tasks, dashboards and users on the new host are built fresh, and that rebuild list is a topic of its own — what a historian migration moves and what you must rebuild covers it. Backup and restore copies the data through the vendor's documented commands, which is why it is the path when nothing may be left behind; if a restore dies on an empty multipart boundary, why influx backup fails with multipart boundary is empty walks that exact symptom.

Telegraf answers neither question: it is a continuous feed, not a bulk history move, which is one reason the reported attempts with it went nowhere. If the new host must also mirror data onward, whether Telegraf can read a local InfluxDB bucket and feed a cloud target covers that separate path.

Decision: selected measurements into renamed buckets — the CSV path below; the entire history with nothing left behind — backup and restore.

How large can one CSV import be on a 2 GB VM? #

Size each import by the memory the import takes, not the file's size on disk, and begin at about 1 MB per file: on the reported 2 GB VM, one 32 MB annotated CSV killed the InfluxDB process, while the split samples imported successfully.

An import holds parsed rows, strings, table metadata, write buffers and storage-engine working data at the same time, so disk size is only a proxy for peak memory. The container's memory limit is a separate constraint from the VM's RAM, and the rest of the stack shares that 2 GB with the database, so the database never gets all of it.

Worked example from the reported case: the full 30-day export measured 1.3 GB, and the same window filtered to one measurement measured 32 MB — a reduction factor of 1300 MB ÷ 32 MB ≈ 41. Split across 30 fixed one-day windows, that is 32 ÷ 30 ≈ 1.1 MB per file, so plan on about 1 MB per import on that host. If a day-file still terminates the process, halve the window to 12 hours — about 0.5 MB each — and grow it back only while imports keep completing.

Quantity Reported value What it decides
VM RAM 2 GB ceiling for the whole container stack, not the database alone
Unfiltered 30-day export 1.3 GB too heavy to import whole
Same window, one measurement 32 MB still fatal as a single file on that VM
One-day window about 1 MB starting file size for the first batch

Read the failure, not just the size. A process that exits points at memory — check the container logs and the VM's memory accounting for an out-of-memory kill — while a rejected upload points at the CSV structure or at organization, bucket or token permissions.

How do you export one measurement to annotated CSV? #

Run influx query with --raw, a range bounded by fixed start and stop timestamps, and a filter on the _measurement column; --raw is what produces annotated CSV, and that one filter is what cut the reported 30-day export from 1.3 GB to 32 MB.

The command, with example values throughout — the dates, names and measurement are examples, and oxygen-sensor is the measurement name from the reported migration:

influx query \
  --org example-org \
  --token "$SOURCE_TOKEN" \
  --raw \
  'from(bucket: "example-bucket")
    |> range(start: 2024-05-01T00:00:00Z, stop: 2024-06-01T00:00:00Z)
    |> filter(fn: (r) => r._measurement == "oxygen-sensor")' \
  > oxygen-sensor-2024-05.csv

Two details decide whether this works. First, _measurement is the measurement-name column, not an ordinary tag: the filter above selects everything logged under that measurement, which is why it removes whole unrelated datasets rather than a few series — and why the reported export shrank so much. Second, prefer fixed timestamps to a relative range such as range(start: -30d), which moves every time you run it; fixed bounds make the windows contiguous and auditable, with no gaps or overlaps between batches.

Keep the Flux expression unchanged and adapt only the shell quoting around it. The token after --token lands in the shell history and in anything you paste afterward; that is the one credential this procedure exposes, and the FAQ below covers the cleanup. If you would rather point and click, the CSV download button in the web interface appears only after a query has run and writes the same annotated CSV into the browser's downloads folder — which is why it is easy to miss while you are hunting for a menu entry.

Where do you cut a large annotated CSV safely? #

Cut nowhere inside a table: an annotated CSV parses only in complete tables, each opening with its own annotation rows for data types and grouping, so re-export a smaller window instead, or cut exactly between two complete annotation blocks if the file already exists.

The annotation rows at the top of each table — the #datatype, #group, #default and #header lines — tell the importer what each column means and how rows group into tables. A cut by byte count or row count can land below them, leaving rows whose types and grouping were defined in rows you just discarded, or inside a quoted field, corrupting a record. That is why the reported split followed the annotated-table boundaries rather than file offsets.

The better move avoids cutting altogether: re-export each window separately, and every file arrives self-contained with its own annotation block. Reserve file-splitting for an export you can no longer regenerate, and cut only at the start of an annotation block.

What is the full import procedure into the new bucket? #

Import one small file first and only then work window by window into the destination bucket, naming the destination organization and bucket explicitly on every write; the influx CLI's write command and the web interface's annotated-CSV upload both accept the same file.

The destination bucket needs two checks before the first batch. Its retention period must cover the oldest timestamp you import — a 7-day retention bucket, for example, will age a 30-day import back out after it lands — and its disk must hold the whole set, which you can size from measured daily growth using the method in estimate historian disk space from measured daily growth.

Then run the migration in this order:

  1. Record the server and CLI versions on both hosts, plus the source and destination organization and bucket names.
  2. Fix the scope: the measurements to move and the exact start and stop timestamps of the history.
  3. Check the destination bucket's retention and free disk against that scope.
  4. Export the first, smallest window with --raw and the measurement filter.
  5. Write that one file into the destination bucket.
  6. Query the destination for that window and confirm the count before continuing.
  7. Repeat export, write and check for each remaining window, logging each file's interval and result.
  8. Run the whole-interval verification from the next section once the last window lands.

Keep the original full export untouched while you work, in case a window needs re-exporting from scratch.

What do you verify after each batch lands? #

A completed upload proves the file parsed, not that the history arrived: compare record counts, earliest and latest timestamps and boundary samples between source and destination over the identical fixed interval before you call the batch done.

Count with the same grouping on both sides — measurement, field and tag — because a grand total can hide one missing series under an offsetting duplicate. Read the earliest and latest timestamps on both sides and inspect samples at every batch boundary for gaps. Spot-check field values, field types and tag sets at the start, middle and end of the interval, and confirm a value you know from the source. Query the destination directly for all of this; a dashboard is not evidence, since its own time range decides what it shows.

Decision, per case: selected measurements into renamed buckets — run the CSV path above and validate every window; the entire history with nothing left behind — backup and restore, not CSV. Keep the source host closed to new writes, or record a cutoff timestamp, until the last window validates; anything written after the cutoff takes one final delta export of its own.

Questions asked

Does the export command leave the token in shell history?

Yes. Anything passed on the command line lands in the shell history and in any log or screenshot of the session. Keep the token in an environment variable or in the CLI's stored connection configuration instead of pasting it inline, and once the migration validates, revoke that token and issue a fresh one for normal operation.

Can an annotated CSV import into a differently named bucket?

Yes. The file carries no organization or bucket identity; both are chosen at write time, which is why the CSV path suits moves into renamed buckets. Name the destination organization and bucket explicitly on every file so no batch lands in a default bucket, and confirm the name in the first validated batch before repeating it.

Why do dashboards stay empty after a verified import?

Most dashboards default to a recent relative time range, so history from past weeks sits outside the window the panel queries. Validate with direct queries using fixed start and stop timestamps first; then widen the dashboard's time range or point its variables at the migrated interval, and the old data appears.

Does annotated CSV migration work between different InfluxDB versions?

The CSV path translates annotated data into line protocol at write time, so the file itself is not tied to one server build; that is also why it works into renamed buckets. The binary backup and restore path is the version-sensitive one, so match it against the restore documentation for your installed release.

Keep reading

  • Explainer

    Can plant historian software run in Docker containers

    The processes will start, but historian services hold retained state and are not documented to communicate statelessly, so a started container proves nothing about collection, calculations, events, or queries surviving replacement. Keep the working deployment in production and evaluate containers only in an isolated test, with a volume mapped for every path that holds data or configuration, passing a counted query across a restart, a recreate, and a host move.

    Edge computing and IIoT

  • How-to

    How two Docker containers share one CSV file on an edge PC

    The vendor Node-RED container stores its CSV through a relative-path bind mount, so no other container can reach it. Declare a Docker named volume, mount it in both the Node-RED and Python services, point the write file node at /mydata, and mount the volume read-only on the Python side.

    Edge computing and IIoT

  • How-to

    Export historian trend CSV at one-minute intervals

    Export the trend's recorded values and you get change-based events, about 17 minutes apart in this case, because the historian stores a value only when it changes. To get one row every minute, query the tag in the Query tool with regularly spaced retrieval at a 60-second interval and export that result; the grid comes from retrieval, not storage.

    Edge computing and IIoT