A simple command-line interface for creating BTRFS snapshots using snapper.
- A Linux distribution with BTRFS file system
- Snapper installed and configured
- Clone this repository or download the
bettersafescript - Make the script executable (if not already):
chmod +x bettersafe - Move the script to a directory in your PATH:
sudo mv bettersafe /usr/local/bin/
Simply run the command without any parameters to enter interactive mode:
bettersafe
You will be prompted to enter a description for the snapshot.
You can also provide a description directly using the -d parameter:
bettersafe -d "My snapshot description"
Note: Any quotation marks in the description will be automatically removed.
The bettersafe CLI is a wrapper around the snapper command that simplifies the process of creating snapshots. It:
- Checks if it's running with sudo privileges and automatically elevates if needed
- Checks if snapper is installed
- Accepts a description via parameter or interactive prompt
- Removes any quotation marks from the description
- Creates a snapshot using snapper
- Displays detailed information about the created snapshot
- Shows information about the previous snapshot and calculates how long ago it was taken
The output will show the complete snapshot details in the same format as snapper list, including:
- Snapshot number
- Type
- Date and time
- User
- Description
It will also show the previous snapshot's details and calculate the time difference between the two snapshots.
Example output:
Snapshot generated:
785 | single | | Fri 18 Apr 2025 04:37:05 IDT | root | | Testing
Previous snapshot:
784 | single | | Fri 18 Apr 2025 04:30:12 IDT | root | | Daily backup
Last snapshot was taken 6 minutes, 53 seconds ago.
The script automatically handles sudo privileges, so you don't need to manually type sudo when running the command. If the script detects it doesn't have the necessary privileges, it will re-run itself with sudo and prompt for your password if needed.
This tool should work on any Linux distribution that supports BTRFS and has snapper installed, including:
- Ubuntu
- Fedora
- openSUSE
- Arch Linux
- And others
If you encounter any issues:
- Ensure snapper is properly installed and configured
- Verify that you have the necessary permissions to create snapshots
- Check that your file system is BTRFS