Upgrading My Digital Ocean Mastodon Instance from 3.5.3 to 4.0.2

Terminal with Mastodon upgrade commands.

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

  • |

    A Training Run Of Reflection

    This morning was not only filled with worship time but also some time of reflecting on the holiday and the joy of celebrating with family the birth of our Savior. I’m thankful for the day we had to put all of the challenges of recent days, weeks, and months aside and enjoy time together with…
  • |

    Sticking To The Plan, An Ready Training Run

    This morning I was able to keep the pace on the slower side. It helped to keep my mind on the worship music and lifting family and the people of a Sierra Leone up in prayer. When you see family struggle and there is not much you can do to help you realize quickly that…
  • |

    Kicking off the First Full Week of 2021

    Every day is a new day, a chance to start again. While in the past my running focused a lot on trying to get faster, and hit another PR, this year feels like it’s it’s going to be a bit more of a reset and restoration year. #HWI #RiverBankRun #Run4Water #WhyIRun
  • |

    Focus And Determination Required For This Training Run

    Today’s training run was an intense interval run that pretty much required my complete focus. I only had 30 seconds to “recover” between my 6 minute long 8 minutes/mile pace intervals, and there were 8 of those. I had quite a few misses, and I was short on my final distance by about .02 miles,…
  • | |

    Tackling 6 Miles On My Last Day In Virginia

    Give the gift of clean water and hope for the future to children and families in Africa: https://timn.me/2Kx7NEr #HWI #Run4Water #WhyIRun #GRMarathon This was one of those tough morning runs, where you have thoughts of quiting early. I didn’t let those feelings stop me, or use the heat and humidity as an excuse. I slowed…

6 Comments

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

Likes

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.)