Terminal with Mastodon upgrade commands.

Upgrading My Digital Ocean Mastodon Instance from 3.5.3 to 4.0.2

For the sake of my own reference, and potentially to help others through the process, I’m documenting and sharing here the steps I took to upgrade my instance, that I host with a Droplet, from version 3.5.3 to version 4.0.2. In the past I’ve had a rough go of it with the upgrades so I figure if any of that happens again I’ll have a record of it here for my own reference as well as for others.

One other item to note is that I made the choice not to jump on the new version 4.x release to just make sure any issues that might have been found were worked out. This was a good choice as within a week of the release things were fixed and we are now on version 4.0.2.

The general upgrade steps to version 4 are found on the releases page in GitHub.

Time needed: 1 hour

Update Steps

  1. Login to your instance console.

    You can use either the , in the Digital Ocean Droplet dashboard, or via using your client of choice.

  2. Shutdown the Mastodon services.

    $ sudo systemctl stop mastodon-*.service

    Note: My Digital Ocean Droplet only has 2GB of RAM, and thus when it comes to compiling the assets steps after an upgrade the process will fail most likely due to the amount of memory required to do that.

  3. Change to the `mastodon` user.

    su - mastodon

  4. Change to the `live` directory.

    cd live

  5. Update to version 3.0.4.

    $ rbenv install --verbose 3.0.4

  6. Set Ruby 3.0.4 as the global default.

    $ rbenv global 3.0.4

  7. Checkout the 4.0.2 release via .

    $ git fetch && git checkout v4.0.2
    Note: that I needed to revert my Gemfile.lock file. git checkout -- Gemfile.lock

  8. Install the dependencies.

    $ bundle install
    then
    $ yarn install

  9. Run pre-deployment database migrations.

    $ SKIP_POST_DEPLOYMENT_MIGRATIONS=true RAILS_ENV=production bundle exec rails db:migrate

  10. Precompile the assets.

    $ RAILS_ENV=production bundle exec rails assets:precompile

    Note: If on this step you get a message Compilation failed: then you may have run out of memory during that step(note my early step about shutting down the Mastodon services). If that happens try to shutdown the services and then also run $ RAILS_ENV=production bundle exec rails assets:clobber and then run the precompile step again.

  11. Restart the Mastodon services.

    $ sudo systemctl restart mastodon-web
    $ sudo systemctl restart mastodon-streaming
    $ sudo systemctl restart mastodon-sidekiq


    Note: It is easier to just exit from being in the mastodon account switching back to root to run those commands. After restarting the services then switch back to the mastodon user for the next step. su - mastodon.

  12. Finish the database migrations.

    Make sure you are back in the ~/live directory as the mastodon user then run the following command:
    $ RAILS_ENV=production bundle exec rails db:migrate

  13. Restart the Mastodon services again.

    See step 11.

Similar Posts

  • /

    Running Is My One On One Time

    It’s still a little bit to get used to doing these longer “midweek” runs on a Monday instead of a Tuesday, but I think I’m getting into a groove with it. It’s nice to have a long “easy” run on a Monday where is can spend a lot of time listening to worship music, listening for God’s direction, and presenting the needs of friends and family to Him. I can honestly say that getting our for a morning run has not only been good for my physical health but it’s had a huge impact on my spiritual health as well. I do enjoy group runs but there is something to be said for having time where it’s just you, the pavement, and God. I spent…
  • Sticking With The Pacers

    I wanted to make sure I hit my target based on how my training went. I decided before the race even started that I was going to stick with the pacers. That plan paid off. Even though my target pace was supposed to be 8:42 min/mi my choices for pacers was 8:30 or 9:00 and so I decided to stick myself in between, but really I just stuck with the 8:30 pacers the whole way, mostly. After hitting mile 10 on Butterworth Street there was a long stretch that was all downhill. I took advantage of that hill and passed the 8:40 pacers. I maintained that position probably up to around mile 14 which is when the mental part of my run had to kick…
  • /

    Getting Out Of The Route Rut

    Water brings hope and changes lives. Water can mean the difference between life and death for many in Africa. Will you be a part of impacting the world with clean water? Join me today! https://timn.me/2Kx7NEr #HWI #Run4Water #WhyIRun #GRMarathon This morning I decided to change up the route quite a bit. Where I went wasn’t completely new but it was an area that I hadn’t been in any of my training routes for awhile. There are a fair amount of places to go for my runs so it’s nice to change things up once in a while.
  • /

    Getting In A Quick Tuesday Training Run

    A well in a village in Africa is an important part of the community, and something to be guarded for sure. You will usually see a fence around the well in order to keep animals and thieves away. There is a national standard for the well pump, which also makes it a target for theft. Clean water is as valuable as gold in some places in the world. #HWI #Run4Water #WhyIRun #GRMarathon Give to Life, Donate Now: https://timn.me/2Kx7NEr

10 Comments

  1. @tim Thanks for sharing. I’m in the process of (slowly, with interruptions) of installing Masto 4 from scratch on a Digital Ocean droplet. When (if?) I complete the process successfully, I’ll put up a post to show what I did.

  2. Thank you. Saving this for when I eventually get around to upgrading. I looked at the official documentation and freaked out.

Mentions

Mentions

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

To respond on your own website, enter the URL of your response which should contain a link to this post's permalink URL. Your response will then appear (possibly after moderation) on this page. Want to update or remove your response? Update or delete your post and re-enter your post's URL again. (Find out more about Webmentions.)