Runbook
Procedures for a running Civility server: upgrade, verify, roll back, back up, and handle incidents. The last section describes how the hosted service at civility.cloud is set up.
The exact commands depend on how you deployed. They are on the Docker and Manual deployment pages. This page gives the order of steps and the rules that apply to both.
Upgrade
- Back up the database and the uploaded files. See Back up.
- Check whether the new version changes the database schema. See Schema changes.
- Install the new version and restart the server.
- Verify the server.
Verify
Run these checks after every upgrade or restore.
curl https://your-domain.com/healthreturns"status": "healthy"and the version you expect.- Sign in at
/loginwith a test account. You land on/. - Open
/admin/and look at/admin/logsfor new errors. - Sync once from an app you know, and open a file that was uploaded before the upgrade.
Roll back
Install the previous version the same way you installed the new one, then restart and verify.
- Docker: rebuild with the previous
CIV_VERSION. - systemd: install
jsr:@civility/cli@<previous version>. - Fly.io:
fly releases --imagelists earlier images, andfly deploy --image <image>runs one.
The previous version must work with the database as it is. If the database itself is damaged, stop the server and restore from a backup.
Schema changes
The server creates its tables the first time it starts on a new database file. It records this in the migrations table as 001_initial.
A release that changes the schema changes 001_initial itself. A database that already recorded 001_initial does not run it again, so an existing database keeps its old tables.
To use a release with a changed schema:
- Keep the old database file and the blob directory.
- Start the new version with a new
--db-path. It creates the new tables there. Give it its own blob directory too (CIVILITY_BLOB_PATH=<new dir>), or pause Blob garbage collection in its/admin/maintenancefirst: a new, empty database knows none of the old files, so its nightly cleanup would delete them. - Move the data you need.
civ api backupdownloads one account's data from a running server as a zip, andciv api restoreloads the zip into an account on another server.
Do not delete the old database until you have checked the new one.
Back up
| What | How |
|---|---|
| Database file | Stop the server and copy the file with its -wal and -shm files, or use sqlite3 .backup while it runs. |
| Uploaded files on disk | Copy the blob directory together with the database. |
| Uploaded files in a bucket | Turn on object versioning at the provider. |
CIVILITY_AUTH_SECRET and the admin token |
Keep a copy outside the server. |
Commands:
Rules:
- Keep backups on a different machine from the server.
- Back up
CIVILITY_AUTH_SECRETwith the database. Without the matching secret, a restored database cannot read the storage, email, billing and service credentials saved in the admin panel, and all sessions end. - Take the database and the blob directory at the same time. The database lists files by their hash, so a database that is newer than the files points at files that are missing.
Restore
Practice a restore every few months.
- Restore the database and the blob directory to a new path or a new volume.
- Start a server on it with the same
CIVILITY_AUTH_SECRET. - Run the Verify checks. Sign in as a known user and download a known file.
- Only then replace the live data.
Commands:
Scheduled jobs
The server runs its own jobs: pruning old change history, blob cleanup, storage snapshots, plan downgrades and removing expired account backups. They only run when the server is started with --unstable-cron. The Docker template and the install command in these docs include it.
Each run is listed in /admin/maintenance and /admin/logs. See Maintenance.
Regular checks
- Look at
/admin/logsfor sign-in failures and bursts ofquota_exceeded. - Watch disk use on the volume that holds the database and the blobs, and bucket use if you have a bucket.
- Check that the last backup exists and is recent.
Incidents
An incident is anything that made the service worse for a user or put data at risk. Do these in order:
- Find out who is affected: one user or everyone. Use
/admin/logs, the server log, and traces if you have observability on. - Check your hosting provider and your bucket provider for outages before you debug the server.
- If the problem started with an upgrade, roll back first and investigate after.
- If data is being damaged, and not only failing to save, stop the server. Start it again only on a version you trust.
| Severity | Meaning |
|---|---|
| S1 | Data lost or damaged, or the whole service is down. |
| S2 | Sign-up, sign-in, sync or billing is broken for everyone. |
| S3 | Partly broken: slow, or one user is blocked. |
| S4 | Caught before any user was affected. |
Common tasks
| Task | Where |
|---|---|
| Create an invite | /admin/invites. Add a note and an expiry, then share the /signup?invite= link. |
| Require an invite to sign up | /admin/invites, "Require an invite to sign up". |
| Raise one user's limits | /admin/users/<id>, "Limit overrides". |
| Change how email is sent | /admin/email. "Send test email" checks the saved settings. |
| Move uploaded files to a bucket | /admin/storage. See Blob storage. |
| Run blob cleanup now | /admin/maintenance, "Run now". Or civ api gc blobs --once --db-path <db> on the server. |
| Look up what a user or admin did | /admin/logs. Filter by user, action or date. Export as CSV or JSON. |
| Export one account's data | See Operations. |
civility.cloud
The hosted service at civility.cloud is one Fly.io machine built from www/Dockerfile. It runs civ api start --site ., which serves the marketing pages, /docs and /blog in front of the app. See Site pages.
| Part | Where |
|---|---|
| Database | SQLite on the Fly volume mounted at /data. The volume ties the app to one machine. |
| Uploaded files | The S3-compatible bucket saved in /admin/storage. |
| Fly secrets | CIVILITY_AUTH_SECRET, CIVILITY_ADMIN_EMAILS, SITE_URL, optionally CIVILITY_ADMIN_TOKEN for scripts, and OTEL_* when telemetry is on. |
| Other settings | Admin panel: storage, limits, tiers, email, billing and service credentials. |
Deploy from the repository root, so that the image can copy docs/:
fly deploy --config www/fly.toml --dockerfile www/Dockerfile .
The image installs the @civility/cli version named by the CIV_VERSION build argument. To release a new server version, change CIV_VERSION. To publish a change to the pages or docs, deploy again.
Before a deploy, run deno task test. After a deploy, run the Verify checks against https://civility.cloud.
Backups: Fly takes a snapshot of the volume every day. Also keep a copy of the database outside Fly. Bucket versioning covers the uploaded files.
Support is by email, best effort, with no guaranteed response time. One person operates the service. When that person is away, the server runs unattended and the scheduled jobs keep running.