Skip to content

dev2-pg-backup: make room before each full dump, fix retention off-by-one - #266

Merged
ralyodio merged 1 commit into
masterfrom
fix/pg-backup-full-headroom
Nov 12, 2026
Merged

ralyodio merged 1 commit into
masterfrom
fix/pg-backup-full-headroom

Conversation

@ralyodio

Copy link
Copy Markdown
Contributor

dev2's / hit 0 bytes on 2026-11-12 08:40 UTC (it got to 6 GB the day before). The cause was the daily dev2-pg-backup.sh full run.

  • /var/backups/postgres held 409 GB: three 57.6 GB nichedb fulls, two 19.8 GB rssamplifier fulls, and 193 GB of 4-hourly dumps.
  • Each 05:20 run writes a new 58 GB nichedb full before older ones are pruned, so ~38 GB free went to 0. The rssamplifier full failed on 11-11 and 11-12, and the bittorrented full failed on 11-12.
  • KEEP_FULL_DAYS=2 used -mtime +2, which only matches files 3 or more whole days old, so three fulls were kept.

Changes

  • make_room_for_full: before each full (shared cluster and per-site stacks), require last full size + FULL_MIN_FREE_GB (default 40). Delete that database's older fulls, never the newest. If there's still no room, skip with an alert instead of filling the disk.
  • Retention uses -mmin +N*1440.

Tested by running make_room_for_full against a scratch dir with fake fulls. With room it touches nothing. With a huge floor it deletes the older nichedb fulls, keeps the newest, leaves nichedbdev-full-* alone, returns 1, and alerts. bash -n passes.

The off-box copy is still missing: the log says "same-box only". seed1, which pulled these, is gone.

🤖 Generated with Claude Code

…-one

The daily full writes a new ~58 GB nichedb dump before the old ones age
out. On 2026-11-11 and 11-12 the 05:20 run took dev2's / from ~38 GB free
to 0, failing the rssamplifier and bittorrented fulls and every write on
the box.

- make_room_for_full: before each full, require the last full's size plus
  FULL_MIN_FREE_GB (default 40). Drop that database's older fulls (never
  the newest) to get there, else skip the dump with an alert.
- Retention uses -mmin: `-mtime +2` only matches files 3+ whole days old,
  so "keep 2 days" kept three nichedb fulls (172 GB).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown

ThreatCrush Security Scan

41 finding(s)

HIGH/CRITICAL: 15 | MEDIUM: 12 | LOW: 14

Severity Rule Location
HIGH py-ssrf-outbound-request dev2/dev2-site:151
HIGH py-ssrf-outbound-request dev2/dev2-site:1099
HIGH py-ssrf-outbound-request dev2/dev2-site:1909
HIGH sh-remote-script-execution root-ubuntu.sh:3262
HIGH sh-remote-script-execution root-ubuntu.sh:3263
HIGH sh-remote-script-execution root-ubuntu.sh:5168
HIGH sh-remote-script-execution root-ubuntu.sh:5172
HIGH sh-remote-script-execution root-w3bs-os.sh:3639
HIGH sh-remote-script-execution root-w3bs-os.sh:3640
HIGH sh-remote-script-execution root-w3bs-os.sh:5569
HIGH sh-remote-script-execution root-w3bs-os.sh:5579
HIGH sh-remote-script-execution root-w3bs-os.sh:5586
HIGH sh-remote-script-execution root-w3bs-os.sh:5602
HIGH sh-remote-script-execution root-w3bs-os.sh:5607
HIGH sh-plaintext-download root-w3bs-os.sh:6289
MEDIUM sql-template-interpolation dev2/dev2-site:1340
MEDIUM sql-template-interpolation dev2/dev2-site:1417
MEDIUM sh-remote-script-execution root-ubuntu.sh:5376
MEDIUM redos-nested-quantifier src/domain-free.ts:56
MEDIUM redos-nested-quantifier src/emoji.ts:167
MEDIUM redos-nested-quantifier src/icon.ts:166
MEDIUM redos-nested-quantifier src/mail.ts:1060
MEDIUM sql-template-interpolation src/users-dump.ts:487
MEDIUM sql-string-concatenation src/users-dump.ts:507
MEDIUM sql-template-interpolation src/users-dump.ts:540
MEDIUM sql-string-concatenation src/users-dump.ts:574
MEDIUM redos-nested-quantifier src/wcag.ts:556
LOW secret-generic-credential src/credentials.ts:41
LOW secret-generic-credential src/credentials.ts:58
LOW secret-generic-credential src/credentials.ts:61
LOW secret-generic-credential src/credentials.ts:66
LOW secret-generic-credential src/user-export.ts:689
LOW secret-generic-credential src/user-export.ts:695
LOW secret-generic-api-key test/credentials.test.ts:208
LOW secret-generic-credential test/mail.test.ts:141
LOW secret-generic-credential test/proxy.test.ts:69
LOW secret-generic-credential test/proxy.test.ts:85
LOW secret-generic-credential test/shorten.test.ts:36
LOW secret-database-url test/users-dump.test.ts:108
LOW secret-database-url test/users-dump.test.ts:119
LOW secret-database-url test/users-dump.test.ts:120

Snippets are redacted; ThreatCrush never prints matched credential material.

@ralyodio
ralyodio merged commit d9a79d5 into master Nov 12, 2026
5 checks passed
@ralyodio
ralyodio deleted the fix/pg-backup-full-headroom branch November 12, 2026 08:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant