Skip to content

Instantly share code, notes, and snippets.

@ksonney
Created November 15, 2022 23:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ksonney/2ff09a5cc3f953c524ee3f97aa20677b to your computer and use it in GitHub Desktop.
Save ksonney/2ff09a5cc3f953c524ee3f97aa20677b to your computer and use it in GitHub Desktop.
Mastodon Update/Upgrade script
#!/bin/bash
# This script works on the theory that you use a tagged image in your docker-compose.yaml
# i.e. "image: tootsuite/mastodon:v4.0.2"
# Make a database backup
docker exec mastodon_db_1 pg_dump -Fc -U postgres postgres > pre-4-0-2.dump
# replace the old tag with the new tag
sed -s 's/v4.0.1/v4.0.2/g' -iv4.0.1 docker-compose.yml
# Pull the new images
docker-compose pull
# run the upgrade/migrations
docker-compose run --rm -e SKIP_POST_DEPLOYMENT_MIGRATIONS=true web rails db:migrate
docker-compose down
docker-compose run --rm web bin/tootctl cache clear
docker-compose run --rm web rails db:migrate
docker-compose up -d
# clean up old, unused images
docker system prune -a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment