The pg_dump
and pg_restore
tools are used to backup and restore the Postgres DB. You can install these tools with Homebrew on macOS without needing to install Postgres itself:
brew install libpq
See the Postgres Tools readme for instructions on how to run a one-off Fly machine that will perform a Postgres backup and upload it to Backblaze B2.
If you don't want to use a Fly machine to perform a remote backup, you can perform one locally.
Create a Postgres backup:
scripts/pg-backup.sh
You'll be prompted for the Postgres password.
This script uses pg_dump
to produce a timestamped, compressed Postgres DB dump and upload it to Backblaze B2 for safekeeping.
More information on pg_dump
:
To communicate with Postgres, first open a local proxy:
fly proxy 5432 --app pie-gd-postgres15
Restore a Postgres backup:
pg_restore --username=postgres --dbname=pie_gd_mastodon <filename>