a super simple program that backups your postgres database
- Rust 96.8%
- Dockerfile 3.2%
|
|
||
|---|---|---|
| .forgejo/workflows | ||
| src | ||
| .gitignore | ||
| Cargo.lock | ||
| Cargo.toml | ||
| config.example.env | ||
| Dockerfile | ||
| mise.toml | ||
| README.md | ||
docker-postgres-backup
dumps a postgres database from a docker container to a directory on a cron schedule.
usage
docker build -t docker-postgres-backup .
docker run -d \
-v /var/run/docker.sock:/var/run/docker.sock \
-v /mnt/cifs/backups:/backups \
--env-file config.example.env \
docker-postgres-backup
configuration
| env var | default | description |
|---|---|---|
DPB_CONTAINER |
required | docker container name or id |
DPB_OUTPUT_DIR |
required | directory to write backups |
DPB_CRON |
0 3 * * * |
cron schedule (utc) |
DPB_PG_USER |
postgres |
postgres username |
DPB_PG_DATABASE |
- | specific db (pg_dump); omit for pg_dumpall |
DPB_PG_PASSWORD |
- | postgres password |
DPB_COMPRESS |
true |
gzip compress output |
DPB_KEEP_N |
10 |
number of backups to keep (0 = off) |
DPB_DISCORD_WEBHOOK |
- | discord webhook url for notifications |
DPB_RUN_ONCE |
false |
run once and exit |
restore
gunzip -c backup_2026-02-27_03-00-00.sql.gz | docker exec -i my_postgres psql -U postgres