pg_dump Partial Backup Disk Full
A backup sidecar can look healthy while quietly publishing an empty or truncated PostgreSQL dump. The dangerous pattern is writing `pg_dump -Fc` directly to the final `.dump` path, then letting retention or offsite upload treat that file as a valid restore point.
Ask free AI judgment
Find what you can delete.
Leave your email now. The scan summary can follow after the first reply; we send the free SafeDisk AI deletion trial step only if deletion risk is still unclear.
Runbook: Never Publish A Failed Dump
- Stop redirecting `pg_dump` directly to the final backup path. Shell redirection creates or truncates that file before `pg_dump` has proved anything.
- Write the dump to a temp path on the same filesystem, for example `app-2026-06-17.dump.partial`.
- Delete an old stale `.partial` for the same job before starting, or make the temp name unique per timestamp.
- Require `pg_dump` exit code 0, a non-empty temp file, and `pg_restore -l` success for custom-format dumps.
- Rename the temp file to the final `.dump` name only after verification passes. This makes final names mean "restore candidate".
- Run offsite upload and retention only after final publication. Failed partials should not prune the previous known-good backup.
- Emit a greppable failure line and call a failure hook such as `BACKUP_ON_FAILURE_CMD` so operators can wire email, Slack, or pager alerts.
Copy-ready issue reply
Use this when a backup sidecar can leave corrupt final dumps.
This keeps the public issue useful: concrete acceptance checks, no private data, and a clear safety boundary.
I would make the backup sidecar publish-by-verification rather than write directly to the final dump path.
Acceptance checks I would add:
- A failing pg_dump never creates or truncates a final app-*.dump / zitadel-*.dump file.
- The dump writes to "$final.partial" on the same filesystem, then renames only after pg_dump exits 0.
- The sidecar verifies test -s "$final.partial" and, for -Fc dumps, pg_restore -l "$final.partial".
- Retention and offsite upload ignore .partial files and do not prune the previous known-good dump after a failed run.
- Failed runs emit a distinct [backup] FAILED line and fire BACKUP_ON_FAILURE_CMD if configured.
- The runbook proves the latest dump is restorable, not just present in ls -lh.
Do Not Delete First
- The previous known-good dump before the replacement dump has passed verification.
- `.partial` files before recording timestamp, size, and the failure that created them.
- Backup logs that prove `pg_dump` exited non-zero or `pg_restore -l` failed.
- Offsite restore points before confirming whether they were uploaded from verified final names or failed partial output.
Free AI deletion trial
Need a delete / confirm / protect answer?
Send the issue link, log excerpt, or storage summary first. We reply with the next safe move and offer the free SafeDisk AI deletion trial only if the incident still needs review.