Jim beat me to blogging it, but on Friday he and I jumped on a stream and migrated a test instance of Mastodon he has that he installed the manual way, over to a new dockerized install using my 1-click installer on Reclaim Cloud.

Things went super smoothly and this should make future upgrades and maintenance super painless. Because the server uses an S3 bucket for its images, really all we needed to do was dump and restore the database, and then fill out the .env file that had settings for Mail and S3. I found most of what I needed to know about the database side e of things from this doc: Migrating to a new machine - Mastodon documentation

And here are the notes I was taking while we were on stream:\


Update .env file

Look at the install’s env.production file and port over any necessary settings in to /root/mastodon/.env

dump the database

su mastodon
pg_dump -Fc mastodon_production -f backup.dump

upload backup.dump to new mastodon install

Just use the file manager if its small, otherwise rsync or sftp.

copy file into db container

docker cp backup.dump postgres:/backup.dump

get a shell inside the database container

docker exec -it postgres bash

make a database

createdb -U mastoson -T template0 mastodon_production

-U mastodon will tell postgres to use the mastodon role, instead of the root role.

restore the database

pg_restore -Fc -U mastodon -n public --no-owner --role=mastodon -d mastodon_production /backup.dump

exit out of postgres container and restart all the containers

docker-compose down && docker-compose up -d && docker-compose logs -f

Things should be working! Now all we need to do is drop the extra db.

go back in to the postgres container and drop db

We don’t need the original database that the installer made, which was called mastodon anymore.

docker exec -it postgres bash
dropdb -U mastodon mastodon