Urgent.News

What's breaking now, across thousands of outlets.

Tech

A nightly pg_dump that fails with the reason, not with "Network is unreachable"

Munchable 's Postgres runs on a hosted tier that provides no managed backups. That makes a nightly GitHub Actions job the only line of defence against data loss, so the workflow is intentionally simple and loud: pg_dump to Cloudflare R2, and if it fails, the platform emails the repo admins. This post is about the checks that were added to it 27 minutes after it first shipped, and the ones that…

Munchable's PostgreSQL database relies on a nightly pg_dump job to protect against data loss. This GitHub Actions workflow is straightforward and vocal: it dumps the database to Cloudflare R2, and if the process fails, platform emails the repository administrators. This article discusses the enhancements made to the backup process 27 minutes after its initial launch, as well as the checks that were present from the outset.

Two archives are created: a full backup containing every schema and row, including the catalog.products table, and a core backup that excludes catalog.products. The full backup is retained for approximately 30 days, while the core backup, which contains critical data such as accounts, entitlements, contribution rewards, and more, is kept for a year. The small archive is uploaded to R2's free storage tier, resulting in near-zero cost.

The backup process includes several checks. Firstly, a preflight step verifies the connection string before pg_dump begins, ensuring that any issues with the connection are identified early. Secondly, it checks if either dump is empty or if the archive is unreadable or truncated, using pg_restore --list to detect issues. Finally, it verifies that the core dump is smaller than the full one, catching any issues with excluded data.

Despite the database provider offering managed backups, Munchable's independent backup job remains crucial for data hygiene. The database is dumped every night at 03:42 UTC, and the restore process has been tested. A previous post covered the deletion of 50,000 rows within a 60-second serverless function, further emphasizing the importance of data management.

Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.

Read the original at dev.to →

More in Tech

More from Thursday 17 September →