Skip to main content

Data and Backups

Everything torq stores lives in a single directory: /data inside the container (TORQ_DATA_DIR).

PathContents
/data/torq.db (+ -wal, -shm)SQLite database in WAL mode
/data/attachments/Uploaded photos, manuals, and invoices
/data/backups/Automatic database copies taken before each schema upgrade (newest 3 kept)
/data/secret.keyEncryption key for 2FA authenticator secrets and SMTP passwords
Back up secret.key together with the database

Never back up torq.db alone without secret.key (or the entire /data volume). Without secret.key, authenticator app codes stop working (users must fall back to recovery codes) and stored SMTP passwords cannot be decrypted.

Creating backups​

Don't copy a live SQLite file directly

Copying /data/torq.db with cp or tar while torq is writing can produce an incomplete or corrupt database. Either use SQLite's online .backup command or stop the container first.

Because the torq image is distroless (it contains no shell or sqlite3), use a temporary Alpine container mounting the same volume:

docker run --rm -v torq-data:/data alpine sh -c \
'apk add --no-cache sqlite >/dev/null && sqlite3 /data/torq.db ".backup /data/backups/manual-$(date +%F).db"'

To back up attachments and secret.key alongside the online database snapshot, copy /data/attachments/ and /data/secret.key as well.

On a VPS, provider disk snapshots (such as Hetzner Backups) are also a reliable extra layer — SQLite in WAL mode recovers cleanly from crash-consistent snapshots.

Vehicle history exports​

Each vehicle's History tab can be printed or exported as JSON or CSV (useful for archiving or handing over to a buyer). New CSV columns are always appended at the end so existing column positions remain stable (hour_meter and hours from v1.7.0, vehicle_type from v1.8.0). When a shop name is configured, CSV exports begin with an instance row and JSON exports include instance.name.

Upgrading​

  1. Read the release notes — the Upgrading section notes whether a release includes database migrations.
  2. Back up first, especially before releases with schema migrations.
  3. Pull the new image and recreate the container (docker compose pull && docker compose up -d). Schema migrations run automatically on startup and only move forward. Before migrating, torq copies the database to /data/backups/ (keeping the newest 3 copies). Do not stop the container while a migration is running.

Rolling back​

Every image is tagged both latest and by commit SHA (ghcr.io/app-torq/torq:sha-<commit>, listed on each release page):

  1. Stop torq.
  2. If the newer version ran a database migration, restore your backup (or the pre-upgrade copy from /data/backups/). Older torq binaries will refuse to run against a newer schema.
  3. Start the earlier image tag (for example ghcr.io/app-torq/torq:sha-<commit>).