Object Lock-aware snapshot deletion: expose deleted snapshots and support undelete
Object Lock-aware snapshot deletion: expose deleted snapshots and support undelete
Summary
When Kopia is used with versioned S3-compatible storage and Object Lock, deleting a snapshot has two different meanings:
- the snapshot is logically deleted from the current repository view;
- the underlying immutable object versions may continue to physically exist and remain recoverable until their retention expires.
Today this distinction is mostly invisible to the user.
I would like to propose three related improvements:
- Object Lock-aware messaging when deleting snapshots;
- the ability to list logically deleted snapshots that are still recoverable;
- a first-class
snapshot undeleteoperation.
The working term used below for the record that reverses a deletion tombstone is resurrection marker.
This proposal is primarily about the CLI and repository semantics. GUI support could be handled separately.
Current behavior
kopia snapshot delete logically removes the snapshot from the current repository view.
With versioned/Object-Locked S3 storage, the historical objects may still physically exist even though the current repository state no longer exposes the snapshot.
Kopia already supports opening a historical S3 repository view using --point-in-time, so the underlying storage can retain enough information to recover an earlier state.
However, there is currently no first-class way to:
- clearly tell the user that a delete is logical while immutable historical versions still exist;
- list snapshots that have been logically deleted but are potentially recoverable;
- undo that logical deletion and return the snapshot to the current repository state.
Proposal 1: Object Lock-aware delete messaging
When deleting a snapshot from a repository with Object Lock enabled, Kopia should make the semantics explicit.
The existing --delete confirmation mechanism should remain the confirmation mechanism; no incompatible CLI behavior is necessary.
For example, without --delete:
Would logically delete snapshot <id>.
Repository Object Lock:
mode: COMPLIANCE
retention period: 7d
The snapshot will disappear from the current repository view, but
historical object versions may remain recoverable while their storage
retention/version history remains available.
Pass --delete to confirm.After confirmation, Kopia could similarly report:
Snapshot <id> has been logically deleted.
Its underlying immutable versions may remain recoverable until their
retention expires and the storage backend is allowed to remove them.Kopia should not claim an exact physical deletion date unless it can determine that date reliably. Object retention, maintenance and storage lifecycle rules may make the actual physical deletion time different from snapshot delete time + retention period.
Repositories without Object Lock should preserve the existing behavior.
Proposal 2: list deleted/recoverable snapshots
Add a way to inspect snapshots that have been logically deleted.
Possible CLI:
kopia snapshot list --deletedor:
kopia snapshot list --include-deletedSuggested information:
snapshot ID
source
snapshot timestamp
deleted timestamp
recovery stateFor example:
2026-09-24 10:15 abc123 deleted:2026-09-24T12:30:00Z recoverableIf Kopia cannot reliably determine whether the underlying versions are still available, the state should be reported as unknown rather than making an unsafe assumption.
Likewise, recoverable-until should only be displayed when it can be calculated reliably.
JSON output should expose the same information in a machine-readable form.
An important implementation detail is that manifest/index compaction can cause the current repository view to stop containing the historical entry even though the protected historical blob versions still physically exist.
The implementation therefore needs to account for repository history rather than assuming the current active index contains every deleted snapshot.
Proposal 3: snapshot undelete
Add a first-class operation such as:
kopia snapshot undelete <snapshot-manifest-id>The purpose is NOT to restore files to the source filesystem and create a new backup.
The purpose is to cancel the logical deletion and make the original snapshot part of the current repository state again.
Conceptually:
active snapshot
↓
deletion tombstone
↓
resurrection marker
↓
active snapshot againHere, resurrection marker is a working term for a newer repository record that supersedes/cancels the logical deletion tombstone.
The exact persisted representation can follow whichever design best fits Kopia's manifest architecture.
Important requirement
Undelete must work even if maintenance or compaction has changed the current indexes after the snapshot was deleted, as long as the required historical blobs/versions are still available.
It must NOT roll the entire repository back to an earlier point in time.
Snapshots created after the deletion must remain untouched.
A possible implementation strategy is:
- obtain the deleted snapshot manifest from retained repository history;
- determine the object/content graph needed by that snapshot;
- ensure the required content/index entries exist in the current repository;
- selectively recover missing index entries from retained pack blobs when necessary;
- verify that the complete snapshot graph is readable;
- only then write the resurrection marker/reactivate the snapshot;
- allow the existing GC mechanisms to undelete contents that become referenced again.
Kopia already contains index-recovery machinery capable of reconstructing index entries from pack blobs, so a selective version of that machinery may be reusable here.
The implementation should determine the safest architecture rather than blindly following the sequence above.
Failure behavior
Undelete should fail closed.
If any required manifest, pack or content is no longer recoverable:
ERROR snapshot cannot be undeleted because required retained data is no longer availableThe repository must remain consistent and the snapshot must remain logically deleted.
The operation should be idempotent.
Running undelete against an already-active snapshot should either succeed as a no-op or return a clear non-destructive message.
Test scenario
This feature should have an end-to-end test against S3-compatible versioned storage with Object Lock enabled, such as MinIO.
The test should create deterministic test files and record cryptographic checksums.
A representative sequence would be:
S1: initial dataset
S2: modify/add/delete files
S3: additional changes
delete S2
S4: additional changes
delete S3
S5: additional changes
run maintenance/compaction
undelete S2
undelete S3The test must verify all of the following:
- active snapshot listing remains correct;
- deleted snapshot listing remains correct;
- snapshots created after deletion are unaffected;
- undelete does not roll the repository back;
- undeleted snapshots become ordinary active snapshots again;
- restoring S2 and S3 produces byte-for-byte identical files;
- SHA-256 checksums match the checksums recorded before deletion;
- deduplicated contents shared with other snapshots remain correct;
- contents unique to deleted snapshots remain recoverable while retained;
- undelete after relevant data has actually disappeared fails safely;
- repeated undelete is safe;
- maintenance before and after undelete does not corrupt repository state.
The feature must not be considered complete merely because the snapshot appears in snapshot list. A real restore with checksum verification is required.
Suggested implementation split
This can be implemented as three independent reviewable PRs:
PR 1 — Object Lock-aware snapshot delete messaging
Small UX-only change with tests.
PR 2 — expose deleted snapshots
Repository API + CLI support for inspecting deleted snapshot state.
PR 3 — snapshot undelete / resurrection marker
Actual recovery/reactivation logic plus the complete MinIO Object Lock end-to-end test.
Keeping these separate should make review and validation significantly easier.
Scope
An initial implementation may target the S3 backend with versioning/Object Lock support.
It should not weaken or bypass Object Lock in any way, mutate immutable historical versions, or require a repository-wide point-in-time rollback.
The normal behavior of repositories without this capability should remain backward compatible.
Source: kopia/kopia