Skip to content

Add portable execution-data export and DynamoDB backup safety #48

Description

@alexeygrigorev

Add portable execution-data export and DynamoDB backup safety

Status: in progress
Tags: backend, data, infra, testing, P0
Depends on: #28 (execution-state schema, resolved)
Blocks: —

Scope

Complete the remaining data-safety gaps for portable execution-data export.
The export command, JSONL format, manifest, validator, redaction rules, and
PITR-enabled tables already exist. This issue adds:

  1. A dry-run import path that validates an export and reports what would be
    written without mutating any data.
  2. A scheduled export endpoint that triggers a portable export and writes it
    to an output location (local dir or S3 URI), callable as an admin job.
  3. A restore drill document covering PITR recovery and portable-export
    validation, with the minimum smoke-check list.

Acceptance Criteria

  • A dry-run import command reads an export directory, runs full
    validation, and reports insert/update/skip/invalid counts per entity
    without writing to any database.
  • Dry-run import exits non-zero when validation fails, zero when valid.
  • Dry-run import reports the total record count it would write.
  • A scheduled export route (POST /api/cron/export) triggers a
    portable export and writes it to EXPORT_OUTPUT_DIR (or S3 when
    configured).
  • The export route returns the manifest summary (entity counts, output
    location) on success.
  • Waiting/follow-up fields (waitingFor, followUpAt) are preserved
    and validated in export/import records.
  • Notification type values including follow-up-due are preserved
    and validated.
  • A restore drill document explains PITR recovery, on-demand backup,
    portable export, validation, dry-run import, and the smoke-check list.
  • Tests cover dry-run import reporting (valid and invalid exports) and
    the scheduled export route.

Test Scenarios

Scenario: Dry-run import of a valid export

Given: a portable export created by writePortableExport
When: dry-run import runs against the export directory
Then: reports the same entity counts as the manifest, exits zero, writes
nothing.

Scenario: Dry-run import of a broken export

Given: an export with a broken task reference and a tampered checksum
When: dry-run import runs against the export directory
Then: reports validation errors, exits non-zero, writes nothing.

Scenario: Scheduled export produces a valid archive

Given: a DynamoDB with seeded execution data
When: POST /api/cron/export runs with EXPORT_OUTPUT_DIR set
Then: returns manifest summary with entity counts, files exist on disk,
and validatePortableExport passes.

Out of Scope

  • Real S3 upload implementation (route writes to local dir; S3 URI support
    documented as a follow-up).
  • Admin auth/access control for the export endpoint (V1 uses the existing
    cron auth path).
  • Multi-table transactional snapshot guarantee (current scan is sequential).
  • File body backup (metadata-only export, as documented).
  • Actual Postgres migration script.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P0Must havebackendBackend/APIdataData model, migration, storageinfraDeployment and infrastructuretestingTests and QA

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions