OS : Debian12
Version minimale de Mastodon : v4.1
Objectif : Mettre en place une purge des données stockées sur votre instance Mastodon
La version 4.1 de Mastodon introduit la fonction de purge des headers et des avatars qui sont, avec le temps, très consommateurs de ressources de stockage. Voici mon script de purge qui prend en compte cette fonctionnalité.
#!/bin/bash
SHELL=/usr/bin/bash
PATH=/home/mastodon/.rbenv/shims:/home/mastodon/.rbenv/bin:/usr/local/bin:/usr/bin:/bin
RAILS_ENV=production
# Prune remote accounts that never interacted with a local user
RAILS_ENV=production /home/mastodon/live/bin/tootctl accounts prune > /var/tmp/mastodon/prune.txt;
# Remove remote statuses that local users never interacted with older than 30 days
RAILS_ENV=production /home/mastodon/live/bin/tootctl statuses remove --days 30 > /var/tmp/mastodon/remove-statuses.txt;
# Remove media attachments older than 30 days
RAILS_ENV=production /home/mastodon/live/bin/tootctl media remove --days 30 > /var/tmp/mastodon/remove-media.txt;
#Remove all headers and avatars older than 30 days
RAILS_ENV=production /home/mastodon/live/bin/tootctl media remove --prune-profiles --days 30 > /var/tmp/mastodon/remove-prune-profils.txt;
# Remove link previews older than 30 days
RAILS_ENV=production /home/mastodon/live/bin/tootctl preview_cards remove --days=30 > /var/tmp/mastodon/remove-preview.txt;
# Remove files not linked to any post
RAILS_ENV=production /home/mastodon/live/bin/tootctl media remove-orphans > /var/tmp/mastodon/remove-orphans.txt;
# Remove remote accounts that no longer exist
RAILS_ENV=production /home/mastodon/live/bin/tootctl accounts cull > /var/tmp/mastodon/accounts_cull.txt;
en tant que utilisateur mastodon:
/home/mastodon/live/bin/tootctl media usage
Avant:
Attachments: 22 GB (277 MB local)
Custom emoji: 792 MB (469 KB local)
Preview cards: 2.56 GB
Avatars: 14.7 GB (2.22 MB local)
Headers: 33.9 GB (3.17 MB local)
Backups: 0 Bytes
Imports: 0 Bytes
Settings: 0 Bytes
Après:
Attachments: 21.4 GB (277 MB local)
Custom emoji: 793 MB (469 KB local)
Preview cards: 2.68 GB
Avatars: 2.77 GB (2.22 MB local)
Headers: 7.9 GB (3.17 MB local)
Backups: 0 Bytes
Imports: 0 Bytes
Settings: 0 Bytes
https://ricard.dev/improving-mastodons-disk-usage/
https://www.mattburkedev.com/adventures-in-mastodon-self-hosting-clean-media-storage-with-tootctl/
https://docs.joinmastodon.org/admin/tootctl/#media-remove