Skip to content

Back up, restore and upgrade

Take consistent backups, restore them, and upgrade between releases.

Updated

Back up the whole data directory with the server stopped, restore it into a fresh directory, and take a backup before every upgrade: there are no downgrade migrations.

What a backup contains

Each index lives in its own directory under the data root:

  • data/
    • indexes/
      • default/
        • events.duckdb
        • events.duckdb.wal
        • archives/ Parquet files
        • temp/
      • payments/
    • .index-trash/ deleted indexes, not a backup

A backup needs both the DuckDB files and the Parquet archives, because neither holds all retained data alone. Archive paths are stored relative to the data root, so a complete data directory can be moved to a new location.

Back up

  1. Stop the service

    On shutdown Logbrook cancels maintenance, drains readers and checkpoints the writer. Stop producers first if you want them to buffer instead of fail.

    docker compose stop logbrook
  2. Copy the entire data directory

    Copy everything, including any WAL file and all archive files, as one backup. For a container volume, use a temporary utility container. This example assumes a Compose project whose volume is named logbrook_logs; check docker volume ls for yours.

    mkdir -p backups
    docker run --rm \
      -v logbrook_logs:/data:ro \
      -v "$PWD/backups:/backup" \
      alpine tar -C /data -czf /backup/logbrook-data.tar.gz .
  3. Start the service again

    docker compose start logbrook

Treat backups as sensitive data: they contain your application logs.

Restore

  1. Restore into a different empty directory or volume

    Do not overwrite a directory that a running server uses.

    docker volume create logbrook_restore
    docker run --rm \
      -v logbrook_restore:/data \
      -v "$PWD/backups:/backup:ro" \
      alpine tar -C /data -xzf /backup/logbrook-data.tar.gz
  2. Fix ownership

    The files must be owned by the service user, UID and GID 10001.

    docker run --rm -v logbrook_restore:/data alpine chown -R 10001:10001 /data
  3. Start one process on it

    Point a single Logbrook process at the restored data, with the same credentials and settings as the original server. For example, with the tokens exported in your shell:

    docker run -d --name logbrook-restore \
      -v logbrook_restore:/data \
      -e LOGBROOK_INGEST_TOKEN \
      -e LOGBROOK_READ_TOKEN \
      ghcr.io/sandrinodm/logbrook:0.5.0
  4. Verify before switching producers

    Check event counts and a few complete events, for example with the CLI. Pick a window that covers the backed-up data, up to 31 days:

    docker exec logbrook-restore logbrook indexes list
    docker exec logbrook-restore logbrook count default --since 7d
    docker exec logbrook-restore logbrook query default --since 7d --limit 5

Upgrade

At startup Logbrook checks schema versions and runs migrations inside a transaction.

  • The hot-table schema is versioned, up to version 4 in this release. An index stays on version 3 until you turn on promoted string attributes, which upgrades that index to version 4.
  • Older archive metadata is migrated before the server starts serving.
  • Startup rejects a database whose schema is newer than the binary supports. A binary that only knows version 3 refuses a version 4 index.
  • There are no downgrade migrations.

To upgrade safely:

  1. Back up

    Take a complete offline backup as described above.

  2. Try the new release on a copy

    Restore the backup into a new directory and start the new version on it. Check counts and sample events.

  3. Upgrade for real

    Stop the service, switch the image tag, and start it again. Pin the tag; see Releases and container images.

To roll back, restore the pre-upgrade backup together with the previous binary or image. Do not run the previous binary on data the new version already migrated.

Forward route changes

These releases changed how Forward Docker routes store events. Neither change needs a data migration, and neither rewrites events already stored.

  • 0.5.0: a Docker route no longer stores the original log line in attributes.docker.log when a JSON line was parsed without loss. The event gets attributes.logbrook.original_line = "omitted" instead. Lines that parsing would change, such as an integer outside the 64-bit range or an object with a repeated key, still keep the line. This is the new default, original_line = "on_parse_failure". To keep the old behavior, set original_line = "always" on the route. Check any query, export or script that reads attributes.docker.log before you upgrade. See original line.
  • 0.4.0: the new route option application_attributes can store the application’s fields at the top level of attributes, where attribute filters can match them. The default, nested, keeps the previous layout, so nothing changes unless you set top_level. See application attributes.

Next steps

Type to search…

↑↓ navigate↵ selectEsc close