Mastodon Server Upgrades
Overview
This provides a guide for upgrading specific versions.
Backup Instructions
These instructions backup the database and environment variables file. It does not back-up media files.
- Create new directory called backups/<DATE>.
- Copy live/.env.production to backups/<DATE> directory.
- Dump database
pg_dump -Fc mastodon_production -f /home/mastodon/backups/<DATE>/backup.dump
Versions
3.4.1
- Stop services -
systemctl stop mastodon-*.service
- Backup database and env file.
- Fetch tags -
git fetch --tags
- Checkout 3.4.1 tag -
git checkout v3.4.1
- Install Ruby dependencies -
bundle install
- Install JS dependencies -
yarn install
- Migrate DB -
RAILS_ENV=production bundle exec rails db:migrate
- Precompile Assets -
RAILS_ENV=production bundle exec rails assets:precompile
- Restart services -
systemctl start mastodon-sidekiq mastodon-web mastodon-streaming
3.4.2
- Stop services -
systemctl stop mastodon-*.service
- Backup database and env file.
- Fetch tags -
git fetch --tags
- Checkout 3.4.2 tag -
git checkout v3.4.2
- Install Ruby dependencies -
bundle install
- Install JS dependencies -
yarn install
- Migrate DB -
RAILS_ENV=production bundle exec rails db:migrate
- Precompile Assets -
RAILS_ENV=production bundle exec rails assets:precompile
- Restart services -
systemctl start mastodon-sidekiq mastodon-web mastodon-streaming
3.4.3
- Stop services -
systemctl stop mastodon-*.service
- Backup database and env file
- Fetch tags -
git fetch --tags
- Checkout 3.4.3 tag -
git checkout v3.4.3
- Install Ruby dependencies -
bundle install
- Install JS dependencies -
yarn install
- Migrate DB -
RAILS_ENV=production bundle exec rails db:migrate
- Precompile Assets -
RAILS_ENV=production bundle exec rails assets:precompile
- Restart services -
systemctl start mastodon-sidekiq mastodon-web mastodon-streaming
3.4.4
- Stop services -
systemctl stop mastodon-*.service
- Backup database and env file
- Fetch tags -
git fetch --tags
- Checkout 3.4.4 tag -
git checkout v3.4.4
- Precompile Assets -
RAILS_ENV=production bundle exec rails assets:precompile
- Restart services -
systemctl start mastodon-sidekiq mastodon-web mastodon-streaming
3.4.5
- Stop services -
systemctl stop mastodon-*.service
- Backup database and env file
- Fetch tags -
git fetch --tags
- Checkout 3.4.5 tag -
git checkout v3.4.5
- Install Ruby dependencies -
bundle install
- Restart services -
systemctl start mastodon-sidekiq mastodon-web mastodon-streaming
3.4.6
- Stop services -
systemctl stop mastodon-*.service
- Backup database and env file
- Fetch tags -
git fetch --tags
- Checkout 3.4.6 tag -
git checkout v3.4.6
- Restart services -
systemctl start mastodon-sidekiq mastodon-web mastodon-streaming
3.4.7
- Stop services -
systemctl stop mastodon-*.service
- Backup database and env file
- Fetch tags -
git fetch --tags
- Checkout 3.4.7 tag -
git checkout v3.4.7
- Restart services -
systemctl start mastodon-sidekiq mastodon-web mastodon-streaming
3.5.0
- Stop services -
systemctl stop mastodon-*.service
- Backup database and env file
- Checkout 3.5.0 tag -
git checkout v3.5.0
- Update available rbenv version -
git -C /home/mastodon/.rbenv/plugins/ruby-build pull
- Install Ruby 3.0.3 -
RUBY_CONFIGURE_OPTS=--with-jemalloc rbenv install 3.0.3
- Install Ruby dependencies -
bundle install
- Install JS dependencies -
yarn install
- Run predeployment DB migration -
SKIP_POST_DEPLOYMENT_MIGRATIONS=true RAILS_ENV=production bundle exec rails db:migrate
- Precompile assets -
RAILS_ENV=production bundle exec rails assets:precompile
- Update service files -
cp /home/mastodon/live/dist/mastodon-*.service /etc/systemd/system/
- Reload systemd daemon -
systemctl daemon-reload
- Restart services -
systemctl start mastodon-sidekiq mastodon-web mastodon-streaming
- Clear cache -
RAILS_ENV=production bin/tootctl cache clear
- Run postdeployment DB migration -
RAILS_ENV=production bundle exec rails db:migrate
- Restart services -
systemctl start mastodon-sidekiq mastodon-web mastodon-streaming
3.5.1
- Stop services -
systemctl stop mastodon-*.service
- Backup database and env file
- Fetch tags -
git fetch --tags
- Checkout 3.5.1 tag -
git checkout v3.5.1
- Install Ruby dependencies -
bundle install
- Install JS dependencies -
yarn install
- Precompile assets -
RAILS_ENV=production bundle exec rails assets:precompile
- Restart services -
systemctl start mastodon-sidekiq mastodon-web mastodon-streaming
3.5.2
- Stop services -
systemctl stop mastodon-*.service
- Backup database and env file
- Fetch tags -
git fetch --tags
- Checkout 3.5.2 tag -
git checkout v3.5.2
- Install Ruby dependencies -
bundle install
- Install JS dependencies -
yarn install
- Run predeployment DB migration -
SKIP_POST_DEPLOYMENT_MIGRATIONS=true RAILS_ENV=production bundle exec rails db:migrate
- Precompile assets -
RAILS_ENV=production bundle exec rails assets:precompile
- Restart services -
systemctl start mastodon-sidekiq mastodon-web mastodon-streaming
- Run postdeployment DB migration -
RAILS_ENV=production bundle exec rails db:migrate
- Restart services -
systemctl start mastodon-sidekiq mastodon-web mastodon-streaming
3.5.3
- Stop services -
systemctl stop mastodon-*.service
- Backup database and env file
- Fetch tags -
git fetch --tags
- Checkout 3.5.3 tag -
git checkout v3.5.3
- Install Ruby dependencies -
bundle install
- Install JS dependencies -
yarn install
- Precompile assets -
RAILS_ENV=production bundle exec rails assets:precompile
- Restart services -
systemctl start mastodon-sidekiq mastodon-web mastodon-streaming
4.0.0
- Stop services -
systemctl stop mastodon-*.service
- Backup database and env file
- Upgade NodeJS -
curl -fsSL https://deb.nodesource.com/setup_16.x | sudo -E bash - && sudo apt-get install -y nodejs
- Install Ruby 3.0.4 -
RUBY_CONFIGURE_OPTS=--with-jemalloc rbenv install 3.0.4
- Fetch tags -
git fetch --tags
- Checkout 4.0.0 tag -
git checkout v4.0.0
- Install Ruby dependencies -
bundle install
- Install JS dependencies -
yarn install
- Run predeployment DB migration -
SKIP_POST_DEPLOYMENT_MIGRATIONS=true RAILS_ENV=production bundle exec rails db:migrate
- Precompile assets -
RAILS_ENV=production bundle exec rails assets:precompile
- Update service files -
cp /home/mastodon/live/dist/mastodon-*.service /etc/systemd/system/
- Reload systemd daemon -
systemctl daemon-reload
- Restart services -
systemctl start mastodon-sidekiq mastodon-web mastodon-streaming
- Run postdeployment DB migration -
RAILS_ENV=production bundle exec rails db:migrate
- Restart services -
systemctl start mastodon-sidekiq mastodon-web mastodon-streaming
4.0.2
- Stop services -
systemctl stop mastodon-*.service
- Backup database and env file
- Fetch tags -
git fetch --tags
- Checkout 4.0.2 tag -
git checkout v4.0.2
- Install Ruby dependencies -
bundle install
- Precompile assets -
RAILS_ENV=production bundle exec rails assets:precompile
- Restart services -
systemctl start mastodon-sidekiq mastodon-web mastodon-streaming
NOTE: Node 18 not supported yet. If you run into issues upgrading directly from 3.5.3, checkout v4.0.0 tag and the upgrade to v4.0.2
4.1.0
- Stop services -
systemctl stop mastodon-*.service
- Backup database and env file
- Fetch tags -
git fetch --tags
- Checkout 4.1.0 tag -
git checkout v4.1.0
- Install Ruby dependencies -
bundle install
- Install JS dependencies -
yarn install
- Run DB migration -
RAILS_ENV=production bundle exec rails db:migrate
- Precompile assets -
RAILS_ENV=production bundle exec rails assets:precompile
- Restart services -
systemctl start mastodon-sidekiq mastodon-web mastodon-streaming
4.1.1
- Stop services -
systemctl stop mastodon-*.service
- Backup database and env file
- Fetch tags -
git fetch && git fetch --tags
- Checkout 4.1.1 tag -
git checkout v4.1.1
- Install Ruby dependencies -
bundle install
- Install JS dependencies -
yarn install
- Precompile assets -
RAILS_ENV=production bundle exec rails assets:precompile
- Restart services -
systemctl start mastodon-sidekiq mastodon-web mastodon-streaming
4.1.2
- Stop services -
systemctl stop mastodon-*.service
- Backup database and env file
- Fetch tags -
git fetch && git fetch --tags
- Checkout 4.1.3 tag -
git checkout v4.1.2
- Update rbenv version -
git -C /home/mastodon/.rbenv/plugins/ruby-build pull
- Install Ruby 3.0.6 -
RUBY_CONFIGURE_OPTS=--with-jemalloc rbenv install 3.0.6
- Install Ruby dependencies -
bundle install
- Install JS dependencies -
yarn install
- Restart services -
systemctl start mastodon-sidekiq mastodon-web mastodon-streaming
4.1.3
- Stop services -
systemctl stop mastodon-*.service
- Backup database and env file
- Fetch tags -
git fetch && git fetch --tags
- Checkout 4.1.3 tag -
git checkout v4.1.3
- Install Ruby dependencies -
bundle install
- Install JS dependencies -
yarn install
- (Optional) Upgrade reverse proxy
Content-Security-Policy: default-src 'none'; form-action 'none'
&X-Content-Type-Options: nosniff
. More info can be found in dist/nginx.conf. - Restart services -
systemctl start mastodon-sidekiq mastodon-web mastodon-streaming
4.1.4
- Stop services -
systemctl stop mastodon-*.service
- Backup database and env file
- Fetch tags -
git fetch && git fetch --tags
- Checkout 4.1.4 tag -
git checkout v4.1.4
- Install Ruby dependencies -
bundle install
- Install JS dependencies -
yarn install
- (Optional) Upgrade reverse proxy
Content-Security-Policy: default-src 'none'; form-action 'none'
&X-Content-Type-Options: nosniff
. More info can be found in dist/nginx.conf. - Restart services -
systemctl start mastodon-sidekiq mastodon-web mastodon-streaming
4.1.5
- Stop services -
systemctl stop mastodon-*.service
- Backup database and env file
- Fetch tags -
git fetch && git fetch --tags
- Checkout 4.1.5 tag -
git checkout v4.1.5
- Install Ruby dependencies -
bundle install
- Install JS dependencies -
yarn install
- Restart services -
systemctl start mastodon-sidekiq mastodon-web mastodon-streaming
4.1.6
- Stop services -
systemctl stop mastodon-*.service
- Backup database and env file
- Fetch tags -
git fetch && git fetch --tags
- Checkout 4.1.6 tag -
git checkout v4.1.6
- Install Ruby dependencies -
bundle install
- Install JS dependencies -
yarn install
- Restart services -
systemctl start mastodon-sidekiq mastodon-web mastodon-streaming
4.1.7
- Stop services -
systemctl stop mastodon-*.service
- Backup database and env file
- Fetch tags -
git fetch && git fetch --tags
- Checkout 4.1.7 tag -
git checkout v4.1.7
- Install Ruby dependencies -
bundle install
- Install JS dependencies -
yarn install --frozen-lockfile
- Restart services -
systemctl start mastodon-sidekiq mastodon-web mastodon-streaming
4.1.8
- Stop services -
systemctl stop mastodon-*.service
- Backup database and env file
- Fetch tags -
git fetch && git fetch --tags
- Checkout 4.1.8 tag -
git checkout v4.1.8
- Install Ruby dependencies -
bundle install
- Install JS dependencies -
yarn install --frozen-lockfile
- Restart services -
systemctl start mastodon-sidekiq mastodon-web mastodon-streaming
4.1.9
- Stop services -
systemctl stop mastodon-*.service
- Backup database and env file
- Fetch tags -
git fetch && git fetch --tags
- Checkout 4.1.9 tag -
git checkout v4.1.9
- Install Ruby dependencies -
bundle install
- Install JS dependencies -
yarn install --frozen-lockfile
- Restart services -
systemctl start mastodon-sidekiq mastodon-web mastodon-streaming
4.2.0
- Stop services -
systemctl stop mastodon-*.service
- Backup database and env file
- Fetch tags -
git fetch && git fetch --tags
- Checkout 4.1.9 tag -
git checkout v4.2.0
- Update Streaming Server Service
sudo cp ~mastodon/live/dist/mastodon-streaming*.service /etc/systemd/system/
sudo systemctl daemon-reload
- Update rbenv version -
git -C /home/mastodon/.rbenv/plugins/ruby-build pull
- Install Ruby 3.2.2 -
RUBY_CONFIGURE_OPTS=--with-jemalloc rbenv install 3.2.2
- Install Ruby dependencies -
bundle install
- Install JS dependencies -
yarn install --frozen-lockfile
- Precompile assets -
RAILS_ENV=production bundle exec rails assets:precompile
- Run predeployment DB migration -
SKIP_POST_DEPLOYMENT_MIGRATIONS=true RAILS_ENV=production bundle exec rails db:migrate
- Restart services -
systemctl start mastodon-sidekiq mastodon-web mastodon-streaming
- Run postdeployment DB migration -
RAILS_ENV=production bundle exec rails db:migrate
4.2.1
- Stop services -
systemctl stop mastodon-*.service
- Backup database and env file
- Fetch tags -
git fetch && git fetch --tags
- Checkout 4.2.1 tag -
git checkout v4.2.1
- Install Ruby dependencies -
bundle install
- Install JS dependencies -
yarn install --frozen-lockfile
- Precompile assets -
RAILS_ENV=production bundle exec rails assets:precompile
4.2.2
- Stop services -
systemctl stop mastodon-*.service
- Backup database and env file
- Fetch tags -
git fetch && git fetch --tags
- Checkout 4.2.2 tag -
git checkout v4.2.2
- Install Ruby dependencies -
bundle install
- Install JS dependencies -
yarn install --frozen-lockfile
- Precompile assets -
RAILS_ENV=production bundle exec rails assets:precompile
4.2.3
- Stop services -
systemctl stop mastodon-*.service
- Backup database and env file
- Fetch tags -
git fetch && git fetch --tags
- Checkout 4.2.3 tag -
git checkout v4.2.3
- Install Ruby dependencies -
bundle install
- Install JS dependencies -
yarn install --frozen-lockfile
- Precompile assets -
RAILS_ENV=production bundle exec rails assets:precompile
4.2.4
- Stop services -
systemctl stop mastodon-*.service
- Backup database and env file
- Fetch tags -
git fetch && git fetch --tags
- Checkout 4.2.4 tag -
git checkout v4.2.4
- Update rbenv version -
git -C /home/mastodon/.rbenv/plugins/ruby-build pull
- Install Ruby 3.2.3 -
RUBY_CONFIGURE_OPTS=--with-jemalloc rbenv install 3.2.3
- Install Ruby dependencies -
bundle install
- Install JS dependencies -
yarn install --frozen-lockfile
- Precompile assets -
RAILS_ENV=production bundle exec rails assets:precompile
4.2.5
- Stop services -
systemctl stop mastodon-*.service
- Backup database and env file
- Fetch tags -
git fetch && git fetch --tags
- Checkout 4.2.5 tag -
git checkout v4.2.5
- Install Ruby dependencies -
bundle install
- Install JS dependencies -
yarn install --frozen-lockfile
4.2.6
- Stop services -
systemctl stop mastodon-*.service
- Backup database and env file
- Fetch tags -
git fetch && git fetch --tags
- Checkout 4.2.6 tag -
git checkout v4.2.6
- Install Ruby dependencies -
bundle install
- Install JS dependencies -
yarn install --frozen-lockfile
4.2.7
- Stop services -
systemctl stop mastodon-*.service
- Backup database and env file
- Fetch tags -
git fetch && git fetch --tags
- Checkout 4.2.7 tag -
git checkout v4.2.7
- Install Ruby dependencies -
bundle install
- Install JS dependencies -
yarn install --frozen-lockfile
4.2.8
- Stop services -
systemctl stop mastodon-*.service
- Backup database and env file
- Fetch tags -
git fetch && git fetch --tags
- Checkout 4.2.8 tag -
git checkout v4.2.8
- Install Ruby dependencies -
bundle install
- Install JS dependencies -
yarn install --frozen-lockfile
4.2.9
- Stop services -
systemctl stop mastodon-*.service
- Backup database and env file
- Fetch tags -
git fetch && git fetch --tags
- Checkout 4.2.9 tag -
git checkout v4.2.9
- Install Ruby dependencies -
bundle install
- Install JS dependencies -
yarn install --frozen-lockfile
4.2.10
- Stop services -
systemctl stop mastodon-*.service
- Backup database and env file
- Fetch tags -
git fetch && git fetch --tags
- Checkout 4.2.10 tag -
git checkout v4.2.10
- Install Ruby dependencies -
bundle install
- Install JS dependencies -
yarn install --frozen-lockfile
4.2.11
- Stop services -
systemctl stop mastodon-*.service
- Backup database and env file
- Fetch tags -
git fetch && git fetch --tags
- Checkout 4.2.11 tag -
git checkout v4.2.11
- Install Ruby dependencies -
bundle install
- Install JS dependencies -
yarn install --frozen-lockfile
- Precompile assets -
RAILS_ENV=production bundle exec rails assets:precompile
4.2.12
- Stop services -
systemctl stop mastodon-*.service
- Backup database and env file
- Fetch tags -
git fetch && git fetch --tags
- Checkout 4.2.12 tag -
git checkout v4.2.12
- Install Ruby dependencies -
bundle install
- Install JS dependencies -
yarn install --frozen-lockfile
- Precompile assets -
RAILS_ENV=production bundle exec rails assets:precompile
4.2.13
- Stop services -
systemctl stop mastodon-*.service
- Backup database and env file
- Fetch tags -
git fetch && git fetch --tags
- Checkout 4.2.13 tag -
git checkout v4.2.13
- Install Ruby dependencies -
bundle install
- Install JS dependencies -
yarn install --frozen-lockfile
4.3.0 NOT WORKING
- Stop services -
systemctl stop mastodon-*.service
- Backup database and env file
- Fetch tags -
git fetch && git fetch --tags
- Checkout 4.3.0 tag -
git checkout v4.3.0
- Install yarn4 -
corepack enable
then,corepack prepare
- Install Ruby dependencies -
bundle install
- Install JS dependencies -
yarn install --immutable
- Generate secrets -
RAILS_ENV=production bin/rails db:encryption:init
- Copy secrets to
.env.production
file - Precompile assets -
RAILS_ENV=production bundle exec rails assets:precompile
- Run predeployment database migrations -
SKIP_POST_DEPLOYMENT_MIGRATIONS=true RAILS_ENV=production bundle exec rails db:migrate
- Restart services -
sudo systemctl restart mastodon-sidekiq mastodon-streaming mastodon-web
- Run postdeployment database migrations -
RAILS_ENV=production bundle exec rails db:migrate
Restart Services
sudo systemctl restart mastodon-sidekiq mastodon-streaming mastodon-web
Documentation
- https://docs.joinmastodon.org/admin/troubleshooting/index-corruption
- https://docs.joinmastodon.org/admin/install/
- https://docs.joinmastodon.org/admin/upgrading/
- https://docs.joinmastodon.org/admin/backups/
- https://docs.joinmastodon.org/admin/migrating/
- https://docs.joinmastodon.org/admin/tootctl/