Skip to content

[T-128] Backup & restore: make backup|restore (pg_dump + artefacts), verified restore test #220

Closed

Description

@CodewithJha

Task T-128 · Milestone M10 — Evaluation · Size S · Priority P1 · Epic #10

Implements NFR-REL-001

Branch ci/t-128-backup-restore-pg-dump-artefacts — one task = one branch = one PR (doc 32 §6)

Summary

Implement doc 29 §7: scripts/backup.sh (pg_dump custom format + artefact root tar with checksums, timestamped) and scripts/restore.sh; CI test restoring into a fresh stack and comparing row counts + artefact hashes.

Context / motivation

Long experiments represent days of compute; losing them is unacceptable.

Scope

In scope

  • Retention count configurable.

Implementation guidance

  • scripts/backup.sh [--out DIR]: pg_dump -Fc via docker compose exec -T db, tar+zstd of the artefact root with a SHA256SUMS manifest, timestamped folder backup-YYYYmmddTHHMMSS; keeps the last BACKUP_RETENTION (default 7).
  • scripts/restore.sh <backup-dir>: refuses a non-empty target DB unless --force is given explicitly, verifies checksums, runs pg_restore --clean --if-exists --no-owner, restores artefacts, then roboprobe db upgrade and roboprobe artifacts verify.
  • CI job: seed the small dataset → backup → fresh stack → restore → compare row counts per table and artefact hashes.
  • make backup / make restore BACKUP=…; update doc 29 §7 with the exact commands.
  • Standards: respect the layering contracts (doc 16 §2) and conventions in doc 34; no hard-coded tunables — thresholds/defaults come from typed settings (doc 27); no magic numbers (ruff PLR2004); public APIs typed (mypy strict) and documented.

Configuration keys

From the configuration reference (doc 27). Keys marked (new) must be added to the typed settings models and appear in the generated reference (T-003c).

  • BACKUP_DIR
  • BACKUP_RETENTION

Acceptance criteria

  • Restore test green in CI.
  • Restore into a non-empty DB without --force aborts with a clear message.
  • CI restore comparison green.
  • Tests listed below added and green in CI; coverage of new code meets the gate in doc 18 §3.
  • Docs, config reference and CHANGELOG Unreleased updated where behaviour, keys or interfaces changed.
  • Definition of Done (doc 32 §3) satisfied.

Tests required

  • tests/integration/test_backup_restore.sh job.

Dependencies

Blocked by: #66 (T-013a), #27 (T-005b)

Blocks: no other task (leaf)

Parallelization notes

Files / paths owned by this task — avoid editing other paths; shared files (pyproject.toml entry points, cli/main.py, api/routers/__init__.py, router.tsx, docker/compose.yaml, ci.yml) are append-only:

  • scripts/backup.sh
  • scripts/restore.sh
  • Makefile (targets)

Independent.

Definition of Done

Per doc 32 §3 and AGENTS.md §5: lint, format, mypy strict and import-linter green; tests added and passing; docs updated; PR template completed with Closes #<this issue>; Conventional Commit messages referencing T-128 (doc 16 §6); commits authored only by the repository owner identity (AGENTS.md §4); CI green; reviewer checklist (doc 32 §5.1) satisfied.

References

Design docs: doc 29 §7 · doc 29 §8 · doc 30 §3

Requirements: NFR-REL-001 (traceability: doc 28)

External:

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:deployDocker images, compose, release packagingarea:storagePostgres schema, repositories, artifactsmilestone:M10M10 — Evaluationpriority:P1Required for milestone exitsize:S<= 1 daytaskChild task of a milestone epictype:infraCI, build, deployment infrastructure

    Projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions