a super simple program that backups your postgres database
  • Rust 96.8%
  • Dockerfile 3.2%
Find a file
tygrdev 293447c99f
All checks were successful
/ build (push) Successful in 51s
fix: trim whitespace
2026-03-01 16:34:35 +00:00
.forgejo/workflows fix: update key 2026-02-27 00:48:30 +00:00
src fix: trim whitespace 2026-03-01 16:34:35 +00:00
.gitignore push shit code :) 2026-02-27 00:38:16 +00:00
Cargo.lock feat: add discord webhook 2026-03-01 15:14:59 +00:00
Cargo.toml feat: add discord webhook 2026-03-01 15:14:59 +00:00
config.example.env push shit code :) 2026-02-27 00:38:16 +00:00
Dockerfile fuck you glib 2026-02-28 17:34:02 +00:00
mise.toml fix: bump rust version 2026-02-27 01:10:01 +00:00
README.md feat: add discord webhook 2026-03-01 15:14:59 +00:00

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