Keeping Mastodon Tidy

If you’re a Mastodon admin and not doing some regular cleanup of your instance, you’ll probably want to.

Mastodon caches tons of stuff – including remote user avatars, remote user headers and link preview card images. A lot of this can safely be cleaned out to free up disk space. This is especially important for those running a single-user instance on a small virtual private server or on tiny home server.

The cached account headers on my instance was taking more storage space (25GB) than the media storage (both local and cached for 14 days) which was around 20GB.

Here’s what it looked like after a little tidying up:

RAILS_ENV=production /home/mastodon/live/bin/tootctl media usage
Attachments:    8.67 GB (744 MB local)
Custom emoji:   482 MB (660 KB local)
Preview cards:  875 MB
Avatars:        693 MB (30.9 KB local)
Headers:        1.81 GB (40.6 KB local)
Backups:        0 Bytes
Imports:        0 Bytes
Settings:       21 KB

Here’s the script that I have cron’d to run daily in order to make sure things are nice and tidy on