Skip to content

Nightly pg_dump

Dump the database, require the fresh dump to exist and be sane, ping the check. The .gz suffix additionally asserts real gzip content, so a truncated or empty dump fails the run instead of silently succeeding:

Terminal window
export BACKPULSE_URL=https://backpulse.aniicrite.dev
export BACKPULSE_PING_KEY='<check-key>'
# crontab: every night at 02:00
0 2 * * * /usr/local/bin/backupctl run \
--path /var/backups/mydb.sql.gz --max-age 26h --min-size 1048576 -- \
/bin/sh -c 'pg_dump -Fc mydb | gzip > /var/backups/mydb.sql.gz'

Or with the pgdump preset β€” same checks, plus a format-magic assertion when the file is a -Fc custom-format dump:

Terminal window
0 2 * * * /usr/local/bin/backupctl run --adapter pgdump \
--path /var/backups/mydb.dump --max-age 26h --min-size 1048576 -- \
pg_dump -Fc mydb -f /var/backups/mydb.dump

--min-size is your tripwire for the classic silent failure: a dump that β€œran” but wrote almost nothing. Set it just under your smallest healthy dump.