Again a quick not for myself and putting a copy here in case something internets goes poof; https://docs.joinmastodon.org/admin/tootctl/#media
tootctl media remove
Removes locally cached copies of media attachments, avatars or profile headers from other servers. By default, only media attachments are removed.
--days N
How old media attachments have to be before they are removed. In case of avatars and headers, how old the last webfinger request and update to the user has to be before they are removed. Defaults to 7.
--concurrency N
The number of workers to use for this task. Defaults to N=5.
--prune-profiles
Instead of media attachments, remove locally cached copies of avatars and headers from other servers. Cannot be combined with --remove-headers.
--remove-headers
Instead of media attachments, remove locally cached copies of headers from other servers. Cannot be combined with --prune-profiles.
--include-follows
Override the default behavior of --prune-profiles and --remove-headers to remove locally cached copies of avatars (and headers) from other servers, irrespective of follow status (by default, they are only removed from accounts that are not followed by or following anyone locally). Can only be used with --prune-profiles or --remove-headers.
--verbose
Print additional information while task is processing.
--dry-run
Print expected results only, without performing any actions.
tootctl media remove-orphans
Scans for files that do not belong to existing media attachments, and remove them. Please mind that some storage providers charge for the necessary API requests to list objects. Also, this operation requires iterating over every single file individually, so it will be slow.
--start-after
The Paperclip attachment key where the loop will start. Use this option if the command was interrupted before.
--dry-run
Print expected results only, without performing any actions.
--prefix
Traverse only a specific prefix of files in the system.
--fix-permissions
Sets S3 ACL to be default according to environment variables.
tootctl media refresh
Refetch remote media attachments from other servers. You must specify the source of media attachments with either --status, --account, --domain, or --days. If an attachment already exists in the database, it will not be overwritten unless you use --force.
--account ACCT
String username@domain handle of the account
--domain DOMAIN
FQDN string
--status ID
Local numeric ID of the status in the database.
--days N
The number of days to limit this task to.
--concurrency N
The number of workers to use for this task. Defaults to 5.
--verbose
Print additional information while task is processing.
--dry-run
Print expected results only, without performing any actions.
--force
Force redownload the remote resource and overwrite the local attachment.
tootctl media usage
Calculate disk space consumed by Mastodon.
tootctl media lookup
Prompts for a media URL, then looks up the status where the media is displayed.
So a new release came out and it is important to get this update as soon as possible! This manual is a transcript of the way that I have updated my Mastodon instance. Please make sure you make proper backups and use your brain while updating things.
A guide to making a Mastodon backup can be found here.
Linux flavour: Debian
Update from: 4.2.xx
Log into your server
su - mastodon
cd /home/mastodon/live
git fetch --tags
git checkout [type the most recent version here, starting with the letter v. For example; v4.2.5
git checkout v4.2.10
If you get a ruby version error, please see bottom of this article for a fix! bundle install
yarn install
RAILS_ENV=production bundle exec rails db:migrate
#NOTE: You might get a ruby error which then suggests you to enter the command "bundle install". Do that and then run the RAILS command again.
My system was unable to find the required v3.2.3 of Ruby and I have fixed this by doing the following steps:
Please make sure that your path is correct.
git -C ~/.rbenv/plugins/ruby-build pull
rbenv install 3.2.3
*WAIT TILL DONE* (it may take a little while)
To check all the installed versions type:
rbenv versions
To set v3.2.3 as the global version, type:
rbenv global 3.2.3
To double-check the active, installed version, type:
rbenv versions
Done!
This manual is a transcript of the way that I have updated my Mastodon instance. Please make sure you make proper backups and use your brain while updating things.
Updating Mastodon and creating backups are important steps to ensure the security and stability of your instance. Here’s a comprehensive tutorial on how to update Mastodon, including making backups of the database and assets:
Note 1: Always perform updates on a test/staging instance before applying them to your live instance. This tutorial assumes you have some basic command line and server administration knowledge.
Note 2: If you made alterations to your files and want to update to a new branch, like v4.2.0, don’t forget to stash your files first. DO THIS AT YOUR OWN RISK.
cd /home/mastodon/live
git stash
You will not have an error message any more when entering: I currently do not know how to put the stashed files back, this will be found out later.
git checkout v4.2.0
Note 3: If you switch to a new branch and version, like 4.2.0, you might run into an error stating the following:
rbenv: version '3.2.2' is not installed (set by /home/mastodon/live/.ruby-version)
Take the following steps to solve this problem: (Type the version you need where it says x.x.x)
rbenv install x.x.x
If that fails, try the following command:
brew update && brew upgrade ruby-build
Followed by: (Type the version you need where it says x.x.x)
rbenv install x.x.x
OPTIONAL: If bundler or rails fails to work, try the following commands:
gem install bundler
gem install rails
Click here for the backup steps. It basically comes down to a Database dump, a settings file backup and a Redis dump. If you wish to backup your assets like images and stuff (User-uploaded files), backup the folder named “public/system”. Keep in mind that this folder can be rather large. Actually, it can become rather massive.
After a good 90 minutes, I gave up on trying to show you how large the asset folder is. So beware if you are going to make a backup of it. Perhaps you can just skip the cache folder?
You can always check the folder size by using NCDU, for which you can find the manual here. Also, installations may vary, but this is an example of my instance.
Upgrade procedure.
su - mastodon
cd /home/mastodon/live
git fetch --tags
git checkout [type the most recent version here, starting with the letter v. For example; v4.0.1
Command example: git checkout v4.0.1
If you don’t want to restart your server, use the following commands instead of “reboot now”:
exit
systemctl restart mastodon-sidekiq
systemctl reload mastodon-web
The reload operation is a zero-downtime restart, also called a “phased restart”. As such, Mastodon upgrades usually do not require any advance notice to users about planned downtime. In rare cases, you can use the restart operation instead, but there will be a (short) felt interruption of service for your users.
The streaming API server is also updated and requires a restart; doing so will result in all connected clients being disconnected, which can increase the load on your server:
systemctl restart mastodon-streaming
Done!
PS: When I updated my instance from 4.1.9 to 4.2.0, a lot of warnings flew by, and this is, in my experience, not a problem as the instance is working perfectly.
This manual is a transcript of the way that I have made a backup of my Mastodon instance. Please make sure you are careful and use your brain while following this manual.
Preparing the backup folder
Log in as root
cd /home/mastodon
mkdir backups
cd backups
Making the backups
Database (three steps)
#NOTE: You might need to elevate to ROOT first before entering the commands in this section below.
su - mastodon
cd /home/mastodon/backups
pg_dump -U mastodon mastodon_production -F t > DATE_FILENAME.tar
Example: pg_dump -U mastodon mastodon_production -F t > 2024-02-02-mastodon_production.tar
You can now check your backups folder to see if all three files are present. This is also a good moment to copy the backup files to another, safe, location.
If you wish to backup your assets like images and stuff (User-uploaded files), backup the folder named “public/system”. Keep in mind that this folder can be rather large. Actually, it can become rather massive.