Skip to content

T-2UB1-backup-undo-recreated-file

State: planning/draft · Impact: low · Complexity: small

Restoring a replaced file offers Undo. Restoring a deleted file does not, so a user who brings back the wrong file has to delete it by hand. Both restores should be undoable the same way.

useBackupRestore.ts shows Undo only when result.replaced is true. Undo restores the path from the safety snapshot. When the restore recreated a deleted file, the path is absent from the safety snapshot, and restore_file refuses a path that does not exist at the given sha (T-7PT3 AC-4). So there is nothing for Undo to call.

  • The backend can undo a recreate. The undo request carries both shas from BackupRestoreResult: safety_sha, where the path is absent, and restored_from, which holds the content the restore wrote. Undo removes the path. It takes its own safety snapshot first, as every restore does, so the recreated file stays recoverable.
  • Before removing anything, the backend compares the file on disk with <restored_from>:<path>. If the user edited it since, the undo is refused with a clear message instead of deleting their edit.
  • The toast offers Undo for both kinds of restore. The undo toast for a recreate says the file was removed again and names the snapshot that holds it.
  1. Decide the API shape: whichever carries both safety_sha and restored_from. That is either an optional expected_from field on BackupRestoreRequest that lets “absent at sha” mean remove, or a separate undo endpoint. Prefer the field if it keeps one code path in restore.rs.
  2. Implement the removal behind the same job key and safety snapshot, with the content check.
  3. Show Undo for recreated files in useBackupRestore.ts and update its tests and the e2e spec.
AreaNote
solutions/determined/crates/determined-backup/src/restore.rsRemove-on-undo with a content check
solutions/determined/crates/determined-core/src/wire/Request or result change
solutions/determined/experiences/backup/app/composables/useBackupRestore.tsUndo for recreated files
solutions/determined/tests/ui/backup/Extend the restore-deleted step with Undo
  • AC-1: After restoring a deleted file, the toast offers Undo, and Undo removes the file.
  • AC-2: The recreated content is in the snapshot taken before the undo.
  • AC-3: If the file changed after the restore, Undo is refused and the file is left as is.
  • AC-4: Undo for a replaced file behaves as before.
  • Undo for folder restores, which do not exist yet.
  • none

← Back to Tasks