Operate the server.

Back up and restore, upgrade with zero downtime, and watch the health endpoints and alerts.

On this page
  1. Back up and restore
  2. Upgrade
  3. Monitor

Back up and restore

Back up two things, and keep them apart:

  • The database. On Postgres, use your usual tooling, for example pg_dump --format=custom or continuous archiving. On SQLite, copy the file with sqlite3 auth.db ".backup backup.db", which is safe while the server runs.
  • The master key. Without it, a restored database has no TOTP secrets and no signing keys.

The database stores tokens only as SHA-256, and every key sealed under the master key, so a database backup alone doesn’t let anyone sign in as your users. Protect it as you protect the master key anyway: it holds every address and password hash.

To restore, load the backup into an empty database, then start the server with the same master key. Sessions created after the backup are gone, so those people sign in again.

Upgrade

Migrations only add tables and columns, so a rollback to the previous minor release keeps working. A database whose schema is newer than the binary stops the server, so an older image never writes to a schema it doesn’t know.

The server has two sets of migrations: the library’s and its own. migrate decides what happens at startup:

  • auto, the default, applies pending migrations under a lock, then serves. Replicas that start at once are safe.
  • check refuses to start while a migration is pending.
  • off skips the check, for operators who apply the library’s migrations with their own tooling.

To upgrade with zero downtime on Postgres:

  1. Read the release’s section in CHANGELOG.md.

  2. Set migrate to check on every replica.

  3. Run the migrations once, as a job with the new image and the servers’ configuration. migrate needs only database_url:

    Shell
    docker run --rm -e TENSILE_AUTH_DATABASE_URL_FILE=/run/secrets/database_url \
      -v "$PWD/database_url:/run/secrets/database_url:ro" \
      ghcr.io/tensile-tools/tensile-auth-server:v0.4.0 migrate
  4. Roll out the new image. Old replicas keep serving against the migrated schema while new ones start.

On a single node, replace the image and keep migrate at auto.

Monitor

The ops port serves two endpoints:

Endpoint Answers 200 when
GET /livez The process serves HTTP. Use it as the liveness probe, so the orchestrator restarts only a hung process
GET /readyz The database answers within 1 second, both schema versions match the binary, the rate-limit backend answers, the background worker is alive, and, with the cache on, the cache watcher is listening. Use it as the readiness probe

When a check fails, /readyz answers 503 with a JSON body that names each failed check, for example {"ready": false, "failed": {"cache_watcher": "…"}}, and logs it at warning level. The checks are database, schema, rate_limits, service, and cache_watcher, and shutdown while the server stops after SIGTERM. tensile-auth-server health asks the local /readyz and exits with 0 or 1; the image’s HEALTHCHECK runs it.

A Kubernetes container spec looks like this:

YAML
livenessProbe:
  httpGet: { path: /livez, port: 9090 }
readinessProbe:
  httpGet: { path: /readyz, port: 9090 }
  periodSeconds: 5

A database outage answers 503 on every API route, never 401, so a person is never signed out by an outage. While the cache watcher is down, the cache is bypassed: the server stays correct, only slower, and /readyz reports it so the orchestrator can route around that replica.

Also watch these:

  • The admin API’s alerts. GET /admin/v1/alerts reports token reuse, leaked tokens, suspected passkey clones, TOTP locks, bursts of failures, sign-up spikes, exports, and late or skipped webhooks.
  • The logs. The server logs JSON to standard error. It never logs a request body, a credential, or a token.