Tidying Mastodon Media with tootctl (Misc)

I've previously posted as part of a wider blog post, but reposting here to make it easier to find.

Mastodon's storage needs can grow over time, especially as more and more external accounts are encountered (leading to additional header images etc).

This snippet provides a set of commands to clear storage out. It assumes that you're running in docker, if that's not the case then just remove the first part of each command (start at tootctl).

Details

  • Language: Misc

Snippet

docker exec -it web tootctl media remove --days=7
docker exec -it web tootctl media remove  --days=7 --prune-profiles
docker exec -it web tootctl media remove --remove-headers
docker exec -it web tootctl preview_cards remove --days 7

# Remove any accounts that no longer exist on the remotes
# best not to run this too regularly as it polls remote servers
docker exec -it web tootctl accounts cull

# Remove any files that exist but aren't referred to in the db
# Note: this is slow...
docker exec -it web tootctl media remove-orphans