Skip to content

Operations and Backups

Guilherme Cardoso edited this page Sep 13, 2026 · 1 revision

Operations and Backups

Back up a running installation

npm run backup

The command writes backups/<timestamp>/ with a consistent flights.db and a copy of flight_plans/, then reopens the database to verify it. An optional destination may be supplied:

npm run backup /path/to/destination

Do not copy an open flights.db alone. SQLite uses WAL mode, so recent commits may still be in flights.db-wal; the result may be stale or inconsistent. The supported command uses SQLite's online backup API.

A copy after a clean shutdown is safe because the server checkpoints on SIGINT or SIGTERM.

Restore

  1. Stop the server cleanly.
  2. Preserve the current data if needed.
  3. Copy the backed-up flights.db and flight_plans/ into the project root.
  4. Start the service and verify the flight list and attachments.

Upgrade security requirements

Deployments from before authentication/TLS enforcement may refuse to start until three requirements are satisfied in sequence:

  1. TLS is configured, or plaintext LAN use is explicitly allowed.
  2. INGEST_TOKEN is configured, or unauthenticated ingest is explicitly allowed.
  3. An operator account exists.

A minimal trusted-LAN migration is:

npm run build
npm run set-password
export INGEST_TOKEN="$(openssl rand -hex 24)"
export ALLOW_PLAINTEXT_HTTP=1
npm start

Prefer TLS, update the agent with the same ingest token and new https:// URL, and configure its certificate trust. Startup validation checks the token before opening the database, so a refusal does not modify flight data.

Maintenance scripts

# Safe online backup
npm run backup

# Fill missing departure/arrival ICAO codes
npm run backfill-icao

# Preview duration corrections, then apply explicitly
npm run backfill-durations
npm run backfill-durations -- --apply

Back up before applying data-changing maintenance.

Clone this wiki locally