Migrating mastodon to a Raspberry Pi 4

I have had a mastodon server running for a couple of years now, and I enjoy a very different social media experience on mastodon than I do on Twitter. Both are good, but they are different.

I originally set up my mastodon instance on a VM, and that was fine. But I’ve been moving some bits to individual Raspberry Pis, and mastodon is one of the servers which I wanted to move.

It was, on the whole, a reasonably simple migration.

The official migration instructions did not quite work. And it is worth noting that the “Detailed steps” only outline some of the steps - you still need to refer back to the earlier “Basic steps” to complete the migration successfully.

The bit which did not work for me was that, having done everything listed here, I could load the mastodon server in my browser, but it displays the normal error message that something has gone wrong.

It gives no hint what it is.

I found a clue in journalctl -u mastodon-web:

ActiveRecord::StatementInvalid (PG::UndefinedTable: ERROR:  relation "ip_blocks" does not exist

Aha. This seemed to point to an error in the database (the “PG” bit / reference to a table).

So perhaps the database migration had not worked correctly.

I also found this closed issue on Github.

It looks like they had had a similar problem.

Their solution was to run:

RAILS_ENV=production bundle exec rails db:migrate

I did this, and it finished (albeit with a warning about risk of corruption, but then a sentence saying not to worry…).

Still no luck.

I did a cache clear:

RAILS_ENV=production bin/tootctl cache clear

And I restarted all the systemd services:

systemctl restart mastodon-sidekiq
systemctl reload mastodon-web
systemctl restart mastodon-streaming

And it worked!

My mastodon instance is now running on a Raspberry Pi 4.