Skip to content

fix: prevent data loss in branch reset with safe clone-then-swap#31

Merged
elitan merged 1 commit intomainfrom
fix/safe-branch-reset
Dec 26, 2025
Merged

fix: prevent data loss in branch reset with safe clone-then-swap#31
elitan merged 1 commit intomainfrom
fix/safe-branch-reset

Conversation

@elitan
Copy link
Owner

@elitan elitan commented Dec 26, 2025

Summary

  • Add renameDataset() method to ZFSManager for safe dataset swaps
  • Replace destroy-then-clone pattern with safe clone-then-swap in branch reset
  • Original dataset preserved until new clone is verified ready

Fixes #21

Test plan

  • All existing reset tests pass
  • Full test suite passes (74 tests)
  • Typecheck passes

🤖 Generated with Claude Code

Previously, branch reset would destroy the existing dataset before
cloning the new snapshot. If the clone operation failed after the
destroy completed, the original dataset would be permanently lost
with no recovery path.

Now uses a safe clone-then-swap pattern:
1. Clone parent snapshot to temporary dataset
2. Mount temp dataset to verify it works
3. Swap datasets via ZFS rename (original preserved as backup)
4. Clean up backup after successful swap

This ensures the original dataset remains intact until the new
clone is verified ready.

Fixes #21

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@elitan elitan merged commit f81c91f into main Dec 26, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: branch reset destroys dataset before clone - unrecoverable on failure

1 participant