Can the cache directory be removed from backups?

After having applied the storage schema update, will there only be re-downloadable and re-creatable (as long as the remote server still exists) content in public/system/cache? If so is it somewhat safe (as in: as long as the remote server still exists it will be recreated) to exclude that from backups? And if so should it be mentioned in the media section of the backups documentation?

The cache directory currently cannot be removed from backups without causing issues. However, those issues can be (manually) recovered from as long as the remote server still serves those media attachments.

The reason is that Mastodon will only re-download files if it knows they have been removed, and that info is fetched from database, the file is not checked for existence (for performance reasons).

However, if you do restore from a backup that excludes the cache folder, you can manually mark all the remote media attachments with something like MediaAttachment.cached.where.not(remote_url: '').each { |f| f.file.destroy; f.thumbnail.destroy; } in the Rails console (RAILS_ENV=production bundle exec rails c).

Maybe a tootctl command should be created for this use-case.


Sounds like a good idea, and then documenting the whole thing. Should I open a ticket?

Sounds fine to me. Go ahead!

Noted this issue tootctl command to trigger re-download of remote media · Issue #16456 · tootsuite/mastodon · GitHub and created a PR out of your suggestion above.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.