feat: back up and restore the release-storage volume, not just Postgres
backup.sh now also streams the fiscal-hub container's release binaries (dist tarball, never in Postgres) into BACKUP_DIR alongside the pg_dump, with the same 14-backup retention; restore_releases.sh is the companion restore. Verified with a real restore smoke test in production: the restored dump's agent_releases row and the restored tarball's exe both match the published sha256 exactly. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
@@ -29,8 +29,21 @@ def test_hub_port_restriction_uses_docker_user_chain():
|
||||
|
||||
|
||||
def test_backup_retention_does_not_delete_on_the_host():
|
||||
# Docker creates the bind-mounted backup directory as root, so a host-side
|
||||
# rm by the deploy user fails once retention kicks in.
|
||||
# The Postgres dump is written by pg_dump INSIDE the postgres container
|
||||
# into the bind-mounted (root-owned) backup dir, so only that container
|
||||
# can rm it. The release-storage tarball is different: backup.sh writes
|
||||
# it itself via host-side shell redirection (`> "$DIR/..."`), so it's
|
||||
# host-owned and a host-side rm is correct there, not a bug.
|
||||
lines = [line.strip() for line in (HUB / "backup.sh").read_text(encoding="utf-8").splitlines() if not line.strip().startswith("#")]
|
||||
retention = [line for line in lines if "rm -f" in line]
|
||||
assert retention and all(line.startswith("$COMPOSE exec -T postgres") for line in retention)
|
||||
assert len(retention) == 2
|
||||
assert retention[0].startswith("$COMPOSE exec -T postgres") and "gti_fiscal_*.dump" in retention[0]
|
||||
assert retention[1].startswith("find \"$DIR\"") and "gti_fiscal_releases_*.tgz" in retention[1]
|
||||
|
||||
|
||||
def test_backup_also_covers_release_storage():
|
||||
# Part H: PostgreSQL alone isn't enough — every published Agent package
|
||||
# binary lives only on the release-storage volume (never in Postgres).
|
||||
script = (HUB / "backup.sh").read_text(encoding="utf-8")
|
||||
assert "fiscal-hub" in script and "/app/data" in script and "releases" in script
|
||||
assert "gti_fiscal_releases_" in script
|
||||
|
||||
Reference in New Issue
Block a user