Upgrades
Upgrade a self-hosted twins server, and roll back safely when a new version migrated the database.
Change the version and run the command you installed with. Roll back safely when a new version migrated the database.
Runs on
Docker Compose · Helm chart · AWS · Google Cloud · Azure
Safety net
The server dumps the database with pg_dump before it migrates, and keeps the newest five
Downtime
The server is away while the new version migrates and takes up its worlds. There is no second copy, by design.
Watch out
Running the old image over a migrated database is not a rollback. Put the database back first.
Prerequisites
On a managed database, the provider's snapshot, taken before you upgrade. See The automatic backup before migrating.
An install from an earlier version: read Upgrading from earlier install versions first.
Steps
Take the managed database's snapshot, if you have one.
Change the version and run the command you installed with:
InstallChangeThen runDocker Compose
TWINS_IMAGEindeploy/.envdocker compose -f deploy/docker-compose.selfhost.yml up -dHelm chart
worlds.image.taghelm upgradeAWS
twins_imageterraform applyGoogle Cloud, Azure
worlds.image.tagin the release'svaluesterraform applyThe server dumps the database, then applies the new version's database migrations as it starts.
The automatic backup before migrating
Before the server migrates a database that an earlier version migrated, it dumps it with pg_dump.
The dump goes to
backups/on the worlds volume (TWINS_DATABASE_BACKUPS,/var/lib/twins/backupsby default). On AWS, that is/twins/backups/on the worlds' file system.A
.jsonfile beside each dump names the versions and thepg_restorecommand.The server keeps the newest five.
A dump it cannot take stops the upgrade. The log says why.
On a managed database, take the provider's snapshot before upgrading in any case. It outlives the worlds volume.
What happens during the upgrade
helm upgrade replaces the twins server in place:
The StatefulSet stops the old copy, then starts the new one.
The new copy applies the database's migrations before its listener opens. It has
worlds.startupSecondsfor this (five minutes by default), the startup probe's budget on/health.It takes the worlds' lock and takes up its worlds, then reports ready on
/ready. This part has no budget: a long restore is waited for, never killed.
The server is away for that time. There is no second copy to take its traffic, by design, and so no PodDisruptionBudget either: a budget for one copy would block every node drain. The console has one and rolls without a gap.
If the new version never becomes ready, or a node dies with the server on it, see Common problems.
Set twins_image to the new version and apply. ECS deploys the server, which applies the new version's migrations as it starts. The new task waits for the old one's lock before it serves. See Deployments and the one writer.
Rolling back
A version refuses a database that a newer version migrated, and says so: "the directory was migrated by a newer build". Running the old image over the new tables is not a rollback.
To go back after an upgrade that migrated, put the database back as it was, then start the old version. The worlds keep what was written since. People, keys and audits go back to the dump.
With the server stopped:
With the chart's own Postgres:
With an external database, restore its snapshot from before the upgrade, or pg_restore the dump into it.
Put the records back from the RDS snapshot you took before the upgrade (restoring from a DB snapshot), or from the dump. Then set twins_image back and apply. The worlds keep what was written since.
Restore the snapshot you took before the upgrade, as the provider does it, then deploy the old version. Or pg_restore the dump into it from any machine that reaches it.
Common problems
"the directory was migrated by a newer build"
Run the newer version, or put the database back from the dump. See Rolling back.
The upgrade stops before it migrates: the dump failed
The log says why. Fix that, or take a snapshot yourself and set TWINS_DATABASE_BACKUPS empty.
Helm: the new version never becomes ready
Roll back, then delete the stuck pod: helm rollback twins, then kubectl -n twins delete pod twins-worlds-0. A StatefulSet does not replace a pod that never became ready on its own, even after a rollback (Kubernetes: forced rollback).
Helm: a node died with the server on it
Kubernetes waits for the node before it starts the copy elsewhere, so two never write the same volume. Once the node is gone for good, kubectl delete node <name> lets it go on.
Helm: the upgrade names a StatefulSet field it cannot change
See "Helm chart: from chart 0.2" below.
Upgrading from earlier install versions
Next
Backups: what to keep, and how to put it back.
Monitoring: what to do when an alert fires.
Last updated: 27 October 2026
Was this helpful?