A powerful and safe shell script for managing ZFS snapshots on Linux systems. Perfect for system administrators and developers who need reliable backup and recovery capabilities.
- Create Snapshots - Timestamped manual snapshots
- List Snapshots - View all available snapshots with creation dates
- Safe Revert - Revert to snapshots with automatic backups
- Destructive Rollback - Clean up snapshot chains when needed
- Delete Snapshots - Remove individual snapshots safely
- Cleanup - Keep only the most recent snapshots
- Auto-completion - Use short snapshot names or full paths
- Safety First - Multiple confirmation prompts for dangerous operations
- Linux system with ZFS support
- Root privileges
- ZFS filesystem (tested on ZFS root systems)
This script works with:
- ZFS Root Systems (like your current setup:
rpool/ROOT/zfsroot) - Non-root ZFS datasets
- Any standard ZFS configuration
Your system uses ZFS as the root filesystem:
sda2 (99.5G) → ZFS Pool 'rpool' → Dataset 'rpool/ROOT/zfsroot' mounted as /
This is an advanced setup that provides excellent snapshot capabilities for your entire system!
# Make executable
chmod +x zfs-snapshot-manager.sh
# View help
sudo ./zfs-snapshot-manager.sh help# List all snapshots
sudo ./zfs-snapshot-manager.sh list
# Create a snapshot
sudo ./zfs-snapshot-manager.sh create
# Delete a snapshot (auto-completes name)
sudo ./zfs-snapshot-manager.sh delete manual_20251027_132704# Safe revert (recommended) - keeps intermediate snapshots + creates backup
sudo ./zfs-snapshot-manager.sh revert manual_20251027_132704
# Destructive rollback - removes intermediate snapshots, no backup
sudo ./zfs-snapshot-manager.sh rollback manual_20251027_132704# Keep only 5 most recent snapshots
sudo ./zfs-snapshot-manager.sh cleanup 5- System recovery after failed updates
- Testing configurations - easily go back
- General use - always creates a backup
- Preserves all intermediate snapshots
- Cleaning up snapshot chains
- When you're absolutely sure you don't need intermediate snapshots
- Disk space recovery - removes intermediate snapshots
- No backup created
# 1. Create snapshot before update
sudo ./zfs-snapshot-manager.sh create
# 2. Perform system update
sudo apt update && sudo apt upgrade
# 3. If something breaks, revert safely
sudo ./zfs-snapshot-manager.sh revert manual_20251027_132704
# 4. Reboot to complete revert
sudo reboot# Keep only last 10 snapshots, delete older ones
sudo ./zfs-snapshot-manager.sh cleanup 10- Format:
rpool/ROOT/zfsroot@manual_YYYYMMDD_HHMMSS - Auto-completion: Use
manual_20251027_132704instead of full name
- No unmounting required for ZFS operations
- Reboot recommended after reverting root filesystem
- Uses native ZFS commands for maximum compatibility
Q: Can I use this on non-root ZFS datasets?
A: Yes! The script automatically detects and handles any ZFS dataset.
Q: What's the difference between revert and rollback?
A: Revert is safe (keeps snapshots + creates backup), rollback is destructive (removes intermediate snapshots).
Q: Do I need to reboot after reverting?
A: For root filesystem reverts, yes. For data datasets, usually not.
Q: How much space do snapshots use?
A: Snapshots use minimal space initially, growing only as files change.
Error: "target is busy"
- This is normal for root filesystem - the script now handles this properly
Error: "Snapshot does not exist"
- Use
listcommand to see exact snapshot names - Or use auto-completion with short names
Error: "Permission denied"
- Run with
sudo- ZFS operations require root privileges
MIT License - feel free to use and modify for your needs.
Found a bug? Have a feature request? Open an issue or submit a PR!
💡 Pro Tip: Use snapshots before major system changes - they're like time machines for your system! 🕰️
This README provides:
- Clear setup instructions for your ZFS root system
- Practical examples for real-world use cases
- Safety guidelines for different operations
- Troubleshooting for common issues
- Friendly tone with emojis and humor
- Technical depth when needed
The script is indeed perfect for your ZFS root setup! 🎯