# Upgrading

Run the new version. Migrations run each time the server starts. Read what changed first.

Paste this into your agent:

> Upgrade my Mailpiece install to the latest version. Read mailpiece.dev/docs/upgrading.md first.

## With Docker

```sh
docker pull ghcr.io/mailpiece/mailpiece:main
docker stop mailpiece
docker rm mailpiece
docker run -d --name mailpiece ...   # the same command as before

# With docker compose
docker compose pull
docker compose up -d
```

## With Kamal

A pull leaves your destination and secrets files alone. Kamal switches over when the new container passes its health check.

```sh
git pull
bundle install
bin/kamal deploy -d production
```

## Going back

Docker: run a build's commit tag, such as `sha-1a2b3c4`, instead of `main`. Kamal: `bin/kamal rollback VERSION -d production` starts the previous container.

Going back does not undo migrations. If the database changed, restore from a [backup](https://mailpiece.dev/docs/backups).

Still need help? Ask on [GitHub](https://github.com/mailpiece/mailpiece).
