Upgrade
Move a self-hosted Cohorly to a new version: back up first, change the image tag, recreate the containers, check the result, and what going back to the previous version means.
An upgrade changes the version of the server and dashboard images. Your data
stays in the selfhost-pgdata volume and the database is migrated by the new
server when it starts.
Install from the first version delivered to you under your contract. Versions before it were never released to customers and are not supported.
Before you start
- Check that your license covers the new version. The key covers images
released up to its
updatesUntildate, and an image released later refuses to start (see License key). Look atGET /api/usageon the running instance to see your date, and renew before you upgrade if the new image was released after it. - Read the changelog for the versions between yours and the new one.
- Take a backup, and keep it. Going back means restoring it, so it must be taken before the new version starts. Follow Backup and restore and put the files somewhere other than the host.
- Check the length of your signing secrets. The API refuses to start when
COHORLY_MCP_JWT_SECRET,COHORLY_MCP_JWT_SECRET_PREVIOUSorCOHORLY_EXPORT_LINK_SECRETis set to fewer than 32 bytes. Replace a shorter one with the output ofopenssl rand -base64 32before you upgrade.
Upgrade
-
Get the new images the way you got the first ones (Getting the images):
-
From the Cohorly registry or your own: nothing to do yet.
-
From the offline package: check and load the new package, then note the repository names
docker loadprints, as they can change.bashsha256sum -c --ignore-missing SHA256SUMSdocker load < cohorly-1.1.0-linux-amd64.tar.gz
-
-
Set the new version in
.env. If you copied the images to your own registry, copy the new tags there first.COHORLY_IMAGE_TAG=1.1.0 -
Pull (skip this step with the offline package) and recreate the containers:
bashdocker compose pull server error-worker dashboarddocker compose up -d --no-buildCompose recreates
server,error-workeranddashboardbecause their image changed, and leavespostgresandcaddyrunning. -
Watch the API start:
bashdocker compose logs -f serverThe server applies the migrations of the new version before it opens its port. They are idempotent and recorded in the
schema_migrationstable, so a start that was interrupted resumes where it stopped. The error worker never migrates: it starts once the API reports healthy. Some index changes on a large events table run in the background after the API is up; a failure is logged and the next start resumes it. -
Check the result:
bashdocker compose pscurl https://cohorly.example.com/healthEvery service should be
healthy, and/healthanswers{"ok":true,"db":true}. Then sign in and open a few reports.
The upgrade has no separate migration command and no separate downtime window beyond the time the API takes to restart and migrate. Events that devices send meanwhile are retried by the SDKs.
Going back
Migrations only go forward. A new version can change the database in ways the previous version does not understand, and there is no command that undoes them. Starting the previous image on a migrated database is not supported.
To go back, restore the backup you took before the upgrade, and run the previous version:
- Stop the stack:
docker compose down(without-v, which would delete your volumes). - Set
COHORLY_IMAGE_TAGin.envto the previous version. - Restore the database, and the blobs if you back them up, from the backup taken before the upgrade. The steps are in Restore.
- Start the stack:
docker compose up -d --no-build.
Anything written after that backup, including events sent after the upgrade, is lost. For that reason, check the new version right after the upgrade, while it is cheap to go back.
If the new image refuses to start with a license message, nothing was
migrated: the license is checked before the database is touched. The instance
is down, though. server keeps restarting, and the dashboard and the error
worker do not start because they wait for the API. Set COHORLY_IMAGE_TAG back
to the previous version and run docker compose up -d --no-build to bring it
back, with its data as it was, or renew the key and run the same command.
Checking the license before you upgrade avoids the outage.