A PostgreSQL backup tool for flestudio.
- Dumps with
pg_dump, compressed as zstd - Uploads to S3-compatible storage (e.g. Cloudflare R2)
- Discord notifications (optional)
- Prunes old local backups by retention
go install github.com/flestudio/pgbackup/cmd/pgbackup@latestnix run github:flestudio/pgbackupNeeds pg_dump on PATH (the Nix package bundles it).
pgbackup --s3-bucket my-bucket --s3-endpoint https://<account>.r2.cloudflarestorage.comOptions can be passed as flags or env vars, and .env is loaded if present.
For the database password, set PGPASSWORD or use .pgpass.
| Flag | Env | Default | Description |
|---|---|---|---|
--database |
DATABASE |
database |
Database name to back up. |
--output-dir |
OUTPUT_DIR |
./backups |
Directory to store local backups. |
--s3-bucket |
S3_BUCKET |
(required) | S3 bucket name. |
--s3-region |
S3_REGION |
auto |
S3 region. |
--s3-access-key |
S3_ACCESS_KEY |
(required) | S3 access key ID. |
--s3-secret-key |
S3_SECRET_KEY |
(required) | S3 secret access key. |
--s3-endpoint |
S3_ENDPOINT |
(required) | S3 endpoint URL. |
--s3-prefix |
S3_PREFIX |
backups |
Key prefix for uploaded objects. |
--discord-webhook-url |
DISCORD_WEBHOOK_URL |
(none) | Discord webhook for notifications (optional). |
--retention-days |
RETENTION_DAYS |
7 |
Delete local backups older than this (0 disables pruning). |
--compression-level |
COMPRESSION_LEVEL |
8 |
zstd compression level (1-22). |
--pg-host |
PGHOST |
(local socket) | PostgreSQL host. |
--pg-port |
PGPORT |
(default) | PostgreSQL port. |
--pg-user |
PGUSER |
postgres |
PostgreSQL user. |