Skip to content

Instantly share code, notes, and snippets.

@TheAlienKnight
Last active November 23, 2022 00:31
Show Gist options
  • Save TheAlienKnight/2fc77a8c5c22e40244ffd4b69233f568 to your computer and use it in GitHub Desktop.
Save TheAlienKnight/2fc77a8c5c22e40244ffd4b69233f568 to your computer and use it in GitHub Desktop.
v3.5.3 to v4.0.0 - Mastodon Docker Migration
#!/bin/bash
echo "Creating backup folder if one doesn't exist already..."
mkdir -p ./backups/3.5.3/
echo "Backing up the Mastodon Database"
docker exec mastodon-db-1 pg_dump -Fc -U postgres postgres > ./backups/3.5.3/pg-3.5.3.dump
echo "Assuming docker-compose.yml exists in this directory, replacing v3.5.3 with v4.0.0"
sed -i 's/v3.5.3/v4.0.0/g' docker-compose.yml
echo "Pulling new versions from dockerhub"
docker compose pull
echo "Performing Pre-deployment database migrations..."
docker compose run --rm -e SKIP_POST_DEPLOYMENT_MIGRATIONS=true web rails db:migrate
echo "Skipping asset compilation, pre-compiled..."
echo "Restarting containers..."
docker compose restart
echo "Performing Post-deployment database migrations..."
docker compose run --rm web rails db:migrate
echo "Recreating containers for good measure (down->up)"
docker compose down
echo "Bringing back up..."
docker compose up -d
echo "Done! All should be well in the world of v4.0.0"
echo "https://github.com/mastodon/mastodon/releases/tag/v4.0.0"
@TheAlienKnight
Copy link
Author

Note: You'll need to change docker compose to docker-compose if not using the apt package (Debian-based). I elect to use it because... well I forget why I chose to do that instead lol.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment