Upgrading Mastodon



My notes for upgrading a dockerised mastodon instance. The mastodon release notes are usually very thorough so always check these for additional steps.

Stop Mastodon services (except the database) and backup database

docker stop mastodon-streaming-1
docker stop mastodon-sidekiq-1
docker stop mastodon-web-1
docker stop  mastodon-redis-1
docker exec mastodon-db-1 pg_dump -Fc -U postgres postgres > ~/backup/2022-12-14-Mastodon.dump

Change the docker-compose.yml to link to the new image

  web:
    image: tootsuite/mastodon:v4.1.1

Pull the new image

docker compose pull

Restart the docker image

docker compose down && docker compose up -d && docker compose logs --follow

Clear the cache

docker exec -it mastodon-web-1 tootctl cache clear

Run any migration scripts

docker exec -it mastodon-web-1 rails db:migrate