# Upgrade dimmi

Upgrade your self-hosted server to the latest release or a pinned version, and learn how to roll back safely.

Always [back up your database](/self-hosting/backups/) first, then upgrade to the latest release with one command:

```bash
dimmictl update
```

Want a specific version? Pass `--version` (browse releases at [github.com/dimmihq/dimmi/releases](https://github.com/dimmihq/dimmi/releases)):

```bash
dimmictl update --version v1.2.3
```

Check which version you are currently running with `cat /opt/dimmi/VERSION`.

## What `dimmictl update` does

1. Downloads the release's stack files into `/opt/dimmi`.
2. Updates `IMAGE` in `/opt/dimmi/.env` to `ghcr.io/dimmihq/dimmi:<version>` and pulls it.
3. Runs `migrate` to apply database migrations.
4. Starts `web` and `worker` on the new image only if migrations succeed, then waits up to 3 minutes for `web` to become healthy.

Updates refresh `compose.yaml`, `Caddyfile`, `postgres-init.sh`, and `.env.example`, while keeping your `.env` untouched. If you customized `compose.yaml` or `Caddyfile`, your previous copy is saved beside it as `.bak`.

If a migration fails, `web` and `worker` stay off the new image. Inspect the error with `dimmictl logs migrate`.

## Roll back to an earlier release

Running `dimmictl update --version <earlier_version>` switches the container image, but it does not undo database migrations. To roll back safely, [restore your pre-upgrade database backup](/self-hosting/backups/) first, then run `dimmictl update --version <earlier_version>`.

---

Index of all dimmi docs: https://trydimmi.com/llms.txt (full text: https://trydimmi.com/llms-full.txt)
