software/Mastodon/admin/backups: Difference between revisions
from HTYP, the free directory anyone can edit if they can prove to me that they're not a spambot
Created page with "==About== Backing up a Mastodon instance requires backing up the following: * media files (may be on another server) * database ===Database=== For reasons unknown to humma..." |
m Woozle moved page Mastodon/admin/backups to software/Mastodon/admin/backups: disambiguate from band (eventually) |
(No difference)
| |
Latest revision as of 19:12, 12 March 2025
About
Backing up a Mastodon instance requires backing up the following:
- media files (may be on another server)
- database
Database
For reasons unknown to hummankind, Mastodon is hard-wired to use PostgreSQL for its main database engine, despite the fact that Mastodon uses Ruby on Rails which provides a database-agnostic framework. The most obvious way to back up Mastodon's data is to use the pg_dump client utility, preferably running on the machine where the backup data will be stored.
Steps:
- Get the PostgreSQL connection credentials. These should be in
Template:Arg/.env.production(DB_*settings). - If the PostgreSQL server is directly accessible:
- Create the
~/.pgpassfile (or modify it) so it has the password for the user you want to connect as. Details are here. - [[[:Template:Hilite]]] From the backup target machine, run:
pg_dump -U Template:Arg -h Template:Arg -p Template:Arg Template:Arg > Template:Arg
- Create the
- If it's not directly accessible, you'll have to tunnel via ssh and I haven't worked out how to do that via CLI.
