11 February
2023
Upgrading Mastodon from v4.0.2 to v4.1.0
I just upgraded norcal.social from Mastodon v4.0.2 to v4.1.0. The upgrade process is easy and the doesn’t require any downtime aside from a few seconds it takes things to start working again after restarting the Mastodon processes. Here are the exact commands to run:
1 2 3 4 5 6 7 8 9 10 11 12 13 |
su mastodon cd pg_dump --clean --create mastodon_production | gzip > mastodon_production.sql.gz cp -a live live.bak cd live git fetch git checkout v4.1.0 bundle install yarn install RAILS_ENV=production bundle exec rails db:migrate RAILS_ENV=production bundle exec rails assets:precompile exit systemctl reload-or-restart mastodon-{web,streaming,sidekiq} |
Some notes:
- This is for a non-docker install.
- Assumes you have initially connected to the server as root.
- Making a backup of the “live” directory probably isn’t necessary. Especially if you have regular backups. You do right? If you are storing media locally then be sure to exclude /home/mastodon/live/public/system/ – to do this you’ll need to use rsync instead of cp.
- If you’ve set “export RAILS_ENV=production” in your .bashrc then you could leave the “RAILS_ENV=production” bit off, but it doesn’t hurt anything to just leave it as-is.
- There was a short lived load spike during the upgrade. Nothing critical, but something to watch out for if you’re server is near capacity and due for an upgrade 🙂
- I’m a fan of cleaning up cruft, so I’d recommend removing the backup data (mastodon_production.sql.gz and live.bak) after 24 hours or whenever you are comfortable that everything is working post upgrade.
- After the mastodon restart it takes a few seconds for things to start working, which means a few seconds of downtime.
- The release announcement can be found https://github.com/mastodon/mastodon/releases/tag/v4.1.0. Check that for full details on the release, and for adjustments to the commands if you are using docker.