Never break your Linux system again. Automatic Btrfs snapshots before every package install, upgrade, or risky command.
# One-line Quick Install
curl -sS https://raw.githubusercontent.com/techoraye/btrfsguard/main/install.sh | sudo bash
- 🎯 What Does It Do?
- ✨ Why BtrfsGuard?
- 🔧 Requirements
- 🚀 Getting Started
- 📦 Supported Distributions & Tools
- 🔥 Real-World Examples
- 🎓 Essential Commands
- 🧠 Smart Features
BtrfsGuard acts as an intelligent safety net for your Linux system. It automatically creates snapshots before you:
- Install/Update Packages (
emerge,apt,pacman,dnf,zypper, etc.) - Run Universal Managers (
flatpak,snap,pip,npm,cargo) - Modify Boot Configs (
grub-mkconfig,mkinitcpio,dracut) - Run Custom Risky Commands (via
snap-wrap)
If something breaks → Just rollback. That's it.
| Problem | BtrfsGuard Solution |
|---|---|
| 😱 System broke after update | 🔄 Rollback in seconds from the GRUB menu |
| 🤔 "What did this install change?" | 📊 See exact file differences with snapper diff |
| 🔥 Kernel panic after upgrade | 🚀 Boot into the "Pre-update" snapshot instantly |
| 💾 Snapshots eating space? | 🧹 Smart deduplication & automatic lock cleanup |
| 🐚 Use Zsh or Fish? | ✅ Native support for Bash, Zsh, and Fish |
BtrfsGuard ONLY works with the Btrfs filesystem. ```bash
df -T /
> [!IMPORTANT]
> If you don't see `btrfs` in the Type column, the installer will safely exit without making changes to your system.
### Other Requirements
* **Root/sudo access**
* **Git** (for auto-updates)
* **Snapper** (auto-installed by the script if missing)
---
## 🚀 Getting Started
### 1. Manual Installation
If you prefer not to use the one-liner, follow these steps:
```bash
git clone https://github.com/techoraye/btrfsguard.git
cd btrfsguard
sudo bash install.sh
You don't need to change your habits. These commands now auto-create snapshots:
sudo emerge -auDN @world
sudo apt upgrade
sudo pacman -Syu
sudo dnf install blender
If a transaction fails or you don't like the changes:
# List snapshots to find your "Pre" ID
snapper list
# Undo the specific changes (example: undoing IDs 10 to 11)
snapper undochange 10..11
| Category | Supported Tools |
|---|---|
| Distros | Gentoo, Arch, Debian, Ubuntu, Fedora, RHEL, openSUSE, Alpine, Void |
| Managers | emerge, apt, pacman, dnf, zypper, apk, xbps-install |
| AUR Helpers | yay, paru |
| Universal | flatpak, snap, pip, npm, yarn, cargo, gem |
| System | grub-mkconfig, update-grub, kernel-install, dracut, mkinitcpio |
- Reboot your PC.
- In the GRUB menu, select "Btrfs snapshots".
- Select the snapshot created right before your last update.
- Once booted, run
sudo snapper rollbackto make it permanent.
Use the built-in wrapper for anything not automatically covered:
snap-wrap rm -rf /etc/some-config-folder
# Snapshot created! If you regret the deletion, undo it instantly.
| Command | Description |
|---|---|
snapper list |
View all system snapshots |
snap-status |
Check BtrfsGuard status and recent activity |
snap-wrap <cmd> |
Manually snapshot a specific command |
snapper-cleanup |
Clean orphaned locks and check storage |
btrfsguard-update |
Check for and install BtrfsGuard updates |
- Nested Snapshot Prevention: If you run a command that triggers a snapshot, and that command calls another command (like
emergecallingdispatch-conf), BtrfsGuard detects the active session and prevents redundant snapshots. - Pre/Post Pairing: Unlike simple cron jobs, BtrfsGuard creates paired snapshots. This allows Snapper to calculate the exact delta (difference) of the transaction.
- Shell Agnostic: Native support for Bash, Zsh, and Fish. It installs the correct aliases and event traps automatically.
BtrfsGuard includes a self-protection update mechanism:
sudo btrfsguard-update
It will:
- Check the GitHub repo for a new version.
- Create a snapshot of your system before updating itself.
- Apply the update and reload your configuration.
Distributed under the MIT License. See LICENSE for more information.
Made with ❤️ for the Linux community