improve backup restore #76

Closed
opened 2026-10-14 15:19:40 +00:00 by jkeffects · 0 comments
Owner

Backup restore: define and implement correct restore behavior (backend)

Restore currently upserts the backup rows and, unless keepNewerData is set, then deletes everything that isn't in the backup. Changed entries are reset to the backup state in both modes. There is no way to just bring back deleted entries, and unique conflicts abort the whole restore.

Restore modes

  • Reset: the selected scope matches the backup exactly
  • Insert missing (new): only bring back deleted entries (ON CONFLICT DO NOTHING)
  • Merge (current keepNewerData): decide whether to compare by updatedAt, drop the mode, or mark it as a special case
  • API: replace keepNewerData with mode and keep the old flag working (it maps to merge)

Scope / partial restore

  • Parent tables are only filled in where rows are missing, never overwritten
  • Child tables affected by cascades are added to the scope or returned for confirmation
  • Report tables that aren't in the backup

Process

  • Pre-check: integrity, signature, app/migration version, schema differences
  • Preview endpoint (dry run): new / changed / deleted per table, cascades, unique conflicts, missing files
  • Create a consistent restore point before restoring
  • Delete first (children → parents), then insert (parents → children)
  • Unique conflicts: report them, then skip or abort
  • Run in chunks (Postgres limit of 65535 parameters)
  • Keep the current credentials/secrets as today
  • Afterwards: run hooks, reload caches/settings, check that files are present, write an audit log entry

Backup creation & retention

  • Create backups in a REPEATABLE READ transaction
  • Manage restore points separately (they shouldn't count for the backup interval or auto-restore)
  • Rotate backups daily / weekly / monthly (new settings)

Files

  • Orphan sweeper moves files to a trash with a retention period instead of deleting them right away
  • Include the file folders in the backup (archive)

Full recovery

  • Evaluate pg_dump plus a file archive (restore, then run migrations)
  • Only allow the JSON restore when the migration version matches, or after the user confirms the schema differences

Rollout

  • Port the changes to ff-admin-server, ff-operation-server and ff-booking-server (hooks, migrations, check mission_tmp_binary)
  • Tests: deleted / changed / new / deleted and recreated with the same unique value / large table / older backup version
## Backup restore: define and implement correct restore behavior (backend) Restore currently upserts the backup rows and, unless `keepNewerData` is set, then deletes everything that isn't in the backup. Changed entries are reset to the backup state in both modes. There is no way to just bring back deleted entries, and unique conflicts abort the whole restore. ### Restore modes - [ ] **Reset**: the selected scope matches the backup exactly - [ ] **Insert missing** (new): only bring back deleted entries (`ON CONFLICT DO NOTHING`) - [ ] **Merge** (current `keepNewerData`): decide whether to compare by `updatedAt`, drop the mode, or mark it as a special case - [ ] API: replace `keepNewerData` with `mode` and keep the old flag working (it maps to merge) ### Scope / partial restore - [ ] Parent tables are only filled in where rows are missing, never overwritten - [ ] Child tables affected by cascades are added to the scope or returned for confirmation - [ ] Report tables that aren't in the backup ### Process - [ ] Pre-check: integrity, signature, app/migration version, schema differences - [ ] Preview endpoint (dry run): new / changed / deleted per table, cascades, unique conflicts, missing files - [ ] Create a consistent restore point before restoring - [ ] Delete first (children → parents), then insert (parents → children) - [ ] Unique conflicts: report them, then skip or abort - [ ] Run in chunks (Postgres limit of 65535 parameters) - [ ] Keep the current credentials/secrets as today - [ ] Afterwards: run hooks, reload caches/settings, check that files are present, write an audit log entry ### Backup creation & retention - [ ] Create backups in a `REPEATABLE READ` transaction - [ ] Manage restore points separately (they shouldn't count for the backup interval or auto-restore) - [ ] Rotate backups daily / weekly / monthly (new settings) ### Files - [ ] Orphan sweeper moves files to a trash with a retention period instead of deleting them right away - [ ] Include the file folders in the backup (archive) ### Full recovery - [ ] Evaluate `pg_dump` plus a file archive (restore, then run migrations) - [ ] Only allow the JSON restore when the migration version matches, or after the user confirms the schema differences ### Rollout - [ ] Port the changes to ff-admin-server, ff-operation-server and ff-booking-server (hooks, migrations, check `mission_tmp_binary`) - [ ] Tests: deleted / changed / new / deleted and recreated with the same unique value / large table / older backup version
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
FF-Admin/ff-admin-core-server#76
No description provided.