The Migration of The Mighty Mastodon

Mastodon Logo

The Twitter Implosion

So what happened? The TL;DR is that one Elon Musk, after a long period of trying not to after making an absurd offer that he was legally enforced to close, has chosen violence and basically done everything he can to drive people and more importantly advertisers away from Twitter. Why? Who knows. I personally suspect that there’s a large amount of ego and self unawareness that he thinks his bravado and brashness will attract people to his supposed genius.

The actual outcome is that a significant volume of people choser to move to another platform with all their friends, a platform known as The Fediverse, and known mostly from a solution called Mastodon, although as a decentralized and open platform, anyone could build a platform and connect to to it and communicate broadly.

The growth is quite something, 3.2 Million new users since Elon started doing silly stuff. There’s a cool Mastodon User Count Bot to see progress.

Mastodon User Count Nov 1 2022 Image: Mastodon User Count Nov 1 2022
Mastodon User Count Dec 29 2022 Image: Mastodon User Count Dec 29 2022

How to join The Fediverse

It really is quite an easy process … the hardest step is deciding which server to join! As a decentralized platform, there is no “one” Mastodon or server where everyone is at. Instead it’s a large group of servers that talk to each other, you can follow anyone anywhere, so the choice to be honest is really about one of two things:

  1. Being on a server that you want to read a local feed of like minded people
  2. Being on a server that has a name, rules or policies that you like.

If you just “want to be able to follow people and post your own content” then frankly any server is fine, including running your own (see the next section).

Once you choose a server, sign up and away you go. For technology and security oriented people, I can highly recommend InfoSec Exchange and Hachyderm both of which I have resided on, are run by great people, and have 30-40,000 people so the Local feed is rich and vibrant.

For those looking for a Safe Place, head to The Intersection which we run for those looking for a place to safely hang out, share and get resurces.

Running your own instance!

OK, the fun stuff!

What if you want to be on The Fediverser with your very own vanity instance, or even host a community? It’s really not that hard!

Why would you want to do this?

  • Because you can. It’s a fun thing, you learn a lot, and have full control.
  • Because you want a vanity handle. @adam@admannz.com is kinda fun and cool
  • Because you want to create a new community of like minded people.

Before you begin

  • You need a domain name. This is the name you type into your browser, like theintersection.app. There are many domain registration sites, I personally use Google Domains because while I have antipathy to the ads side of Google, working there I saw how amazing they are at cloud infrastructure. You can always move the domain registrar later if you want.
  • You need to make a choice on hosting. There are 3 common options:
  • Hosted Mastodon. A lot of these platforms are currently not accepting new registrations due to the overload of migrations, but these are a fast and low cost way to get started. All the infrastructure and running of Mastodon is done for you (that’s what you pay for), you just create a server and attach your domain name to it. A partial list is provided here.
  • Run a virtual server in the cloud. This means signing up for an account at somewhere like Amazon AWS, Google Cloud, Azure, Oracle Cloud, Digital Ocean and a plethora of others. You deploy the server and do all the configuration, you are paying for the hardware hosting, network traffic etc.
  • Run a server yourself at home, the same as the item above, but you provide the hardware and do it all yourself. I am doing this, technically I’m running a VM to make it easier to snapshot and backup, but I also played with physical hardware as I went through many iterations of installing to see what worked best. I intend on migrating to a hosted server setup for reliability reasons, it’s fine when it’s just me messing around but if/when others rely on it, gotta be a little more serious.
  • Prepare for the installation (assuming you go with item 2 or 3, if you went with hosted, the rest of this post does not apply to you, go have fun configuring!)
  • Download and install or choose to deploy Ubuntu Server. I would recommend 22.04 LTS. I tried 22.10 but something has changed as the instructions continually failed and I couldn’t be assed figuring it out. You can choose many platforms, I find Ubuntu to be a well supported distro and easy to work with.
  • Configure SSH keys. Do not use a username/password to SSH into the server, use SSH Keys. Assuming you are on a Mac or Linux:
  • On the Mac/Linux run “ssh-keygen -t rsa” (minus quotes)
  • On the Mac/Linux run “ssh-copy-id -i [path to the file you just created] serverusername@serverhost
  • On the Mac/Linux run “ssh-add [path to the file you just created]
  • You can now SSH to the server using that key. If you use a second laptop/desktop you will need to either repeat this or reuse the keys you just created (in security terms reuse is bad, in practical terms there are worse things you can do).
  • Prepare the VM or server. These steps essentially update the server and apply appropriate security configurations as a baseline.
  • Set up an SMTP relay, you will need to be able to send and receive email to create an account in your new instance. I followed these instructions to set up SendInBlue which is free for up to 300 emails per day, more than enough for my use case. You will create an account, configure your DNS domain and install the required packages of your server.

Now you can install Mastodon 🙂

I unashamedly have used Linux Babe’s instructions as they work, every time. Just follow the instructions step by step, I literally copy/paste each command.

  • Note that this is an “all-in-one” server, it will scale to a point, but if you end up hosting a larger population there will be scale out tasks down the line 🙂
  • After the installation, browse to your new server, login with the first admin account and temp password provided, set a good new password and enable 2FA under Preferences-Account. This is the account you should use to configure the server, separate from your own daily user account.
  • Invite your own personal account and start following and posting etc.

Post installation tasks

  • Move the media storage to AWS S3
  • I started with these instructions which are fairly straight forward … Create an S3 bucket, set an API user to get a key/secret combo, install S3cmd and sync any existing information from the current /public/system folder, addlines to the .env.production configuration file and you’re good to go.

Monitor the server

I am running a basic setup of Monitorix. It can be a little fiddly to configure, but it does provide a nice dashboard.

Monitorix Dashboard Image: Monitorix Dashboard - Postgres

And lastly, set backups!

I run the following backup script each night and copy the backups off to another location.

#!/bin/bash
white='\e[0;37m'
yellow='\e[0;33m'
date +"%FORMAT_STRING"
date +"%m_%d_%Y"
date +"%Y-%m-%d"
var=$(date +"%FORMAT_STRING")
now=$(date +"%m_%d_%Y")
printf "%s\n" $now
today=$(date +"%Y-%m-%d")
#Mastodon app folder backup
#tar cvpzf /backup/[filename]-$now.tgz /var/www/mastodon
#Copy SSL keys
#echo -e "${yellow}Dumping SSL keys to TGZ file$white"
#tar cvpzf /backup/SSLkeys-$now.tgz /etc/letsencrypt/live
#Copy NGINX configs
#echo -e "${yellow}Dumping NGINX configs to TGZ file$white"
#tar cvpzf /backup/nginx-$now.tgz /etc/nginx/conf.d/
#Mastodon database dump
echo -e "${yellow}Dumping Mastodon Postgres database to TAR file$white"
#rm /backup/*.tar
sudo -u postgres -i pg_dump -F t mastodon > /backup/[filename]_pgsql-$now.tar
sudo s3cmd put /backup/*.t* s3://[S3bucketname]
printf "%b\n" "mastodon_pgsql-$now backup complete" >> /backup/log.txt
echo "[backupname] $now backup complete" | mailx -r notifications@[yourdomain] -s backupreport [user@email.com]

So, it’s a bit of work to set up and run, but it is fun. Enjoy :)