Automated USB backup agent written in Rust. This program runs 24/7 and instantly detects USB device connections to trigger predefined actions.
Version Française ici (French Version)
- Real-time Monitoring: Detects connect/disconnect events without polling (using native APIs via
nusb). - Standard XDG Paths: Configuration and logs now follow Linux standards (
~/.config/usbackupand~/.local/share/usbackup). - Incremental Snapshots: Supports time-based versioning using
rsynchard links (Space efficient versioning). - Post-Backup Actions: Automatically unmount devices or run custom scripts after successful backups.
- Decentralized Configuration: Configuration is stored directly on the USB devices (
.usbackup.toml), making it portable. - HMAC Security: Configurations are cryptographically signed using a local secret key to prevent unauthorized execution.
- Smart Auto-mount: Automatically finds and mounts USB partitions using
udevandudisksctl. - Interactive Whitelisting: When a new device is detected, the app asks whether to remember it, ignore it, or ask again later.
- Background Agent: Multi-threaded architecture to keep the task responsive during backups.
- System Notifications: Uses native desktop notifications to keep you informed.
USBackup uses a Decentralized Configuration model with a Zero-Trust security approach:
- Detection: Listens to
udevevents vianusbfor instant device detection (no polling). - Identification: Uses the partition UUID to distinguish between different USB devices.
- HMAC Signature:
- A unique
secret_keyis generated on your machine. - Each device config (
.usbackup.toml) is signed with this secret using HMAC-SHA256. - This prevents malicious users from injecting their own configuration to steal files.
- A unique
- Execution:
- Mirror Mode: Simple one-way synchronization.
- Incremental Snapshots: Using
rsync --link-destto create time-stamped versions with minimal disk usage. - Post-Backup: Automatic unmount or custom script execution.
- Smart Exclusions: Automatically respects your project's
.gitignorerules.
| OS | Status | Notes |
|---|---|---|
| Linux | ✅ Supported | Native support for udev and auto-mount. |
| Windows | ❌ Not Supported | If you want Windows support, please Fork + PR. |
| macOS | ❌ Not Supported | If you want macOS support, please Fork + PR. |
You need libudev development files installed on your system:
- Fedora/RHEL:
sudo dnf install libudev-devel - Ubuntu/Debian:
sudo apt install libudev-dev pkg-config
- Ensure you have Rust installed.
- Clone the repository.
- Build and run:
cargo run
USBackup uses a decentralized configuration model.
- Local Config: Stored in
~/.config/usbackup/backup_config.toml, it contains the list of approved UUIDs and your machine-specific secret key. - Logs: Detailed logs are kept in
~/.local/share/usbackup/logs/. .usbackup.toml(Device): Stored on the root of your USB key. It contains the backup rules and the HMAC signature.
name = "My SanDisk Key"
vendor_id = 1921
product_id = 21889
uuid = "1234-ABCD"
signature = "a1b2c3d4..."
action = "Whitelist"
[[backup_rules]]
source_path = "/home/user/Documents"
destination_path = "backups/docs"
exclude = [".tmp", "cache/"]
incremental = true # Enable snapshots
unmount_after = true # Auto unmount
post_backup_script = "notify-send 'Backup Done!'"Whitelist: Automatically triggers backups.IgnoreForever: Stops asking and ignores the device.AskEachTime: Prompts for action every time the device is plugged in.
- Decentralized TOML configuration.
- HMAC Signature for configuration security.
- Automatic partition mounting.
- Standard XDG paths for config and logs.
- Incremental snapshots (versioning).
- Post-backup actions (script/unmount).
- System notifications.
- Multi-target backup (Remote SSH/Cloud).
MIT