Operate the server.
Back up and restore, upgrade with zero downtime, and watch the health endpoints and alerts.
On this page
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=customor continuous archiving. On SQLite, copy the file withsqlite3 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.checkrefuses to start while a migration is pending.offskips the check, for operators who apply the library’s migrations with their own tooling.
To upgrade with zero downtime on Postgres:
-
Read the release’s section in
CHANGELOG.md. -
Set
migratetocheckon every replica. -
Run the migrations once, as a job with the new image and the servers’ configuration.
migrateneeds onlydatabase_url:Shelldocker 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 -
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:
livenessProbe:
httpGet: { path: /livez, port: 9090 }
readinessProbe:
httpGet: { path: /readyz, port: 9090 }
periodSeconds: 5A 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/alertsreports 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.