thwapback
thwapback is a shell script that provides a simple interface for performing backups using borgbackup (full backups) and rdiff-backup (work backups). Repositories are stored under /srv/backup/{borg,rdiff} at a SHA256-hashed path keyed by OS (normalized: Linux/FreeBSD), architecture (normalized to BSD style: amd64/arm64), fully-qualified hostname, and username. A human-readable recovery symlink tree is automatically created at <base>/recovery/<OS>/<arch>/<hostname>/<user> pointing to the hashed repository. FUSE mounting uses friendly paths under /tmp/{borg,rdiff}/<OS>/<arch>/<hostname>/<user>. It also supports rotating backups with tagged intervals (hourly/daily/weekly/monthly/semiannual/annual/onetime) and sending notifications via the 9P protocol.
Requirements
- borgbackup (for full backups)
- rdiff-backup (for work backups)
- borgfs (optional, for mounting borg repositories)
- rdiff-backup-fs (optional, for mounting rdiff-backup repositories)
- 9p (optional, for sending notifications)
Installation
- Place
thwapback.sh somewhere in your PATH (e.g., ~/bin/thwapback).
- Make it executable:
chmod +x ~/bin/thwapback
- (Optional) Create a configuration file at
~/.config/thwap/thwapback.conf to override default settings.
Usage
thwapback <CMD> [ARGS]
Commands
| Command |
Description |
full |
Perform a full backup using borgbackup |
work |
Perform a work backup using rdiff-backup |
help |
Show general help |
Full backup options (thwapback full [ARGS])
| Flag |
Description |
-c <file> |
Use an alternative configuration file |
-R |
Rotate backups after completion (default) |
-N |
Do not rotate backups after completion |
-h |
Tag backup as hourly |
-d |
Tag backup as daily |
-w |
Tag backup as weekly |
-m |
Tag backup as monthly |
-s |
Tag backup as semiannual |
-a |
Tag backup as annual |
-r |
Tag backup as one‑off |
-M |
Mount the borg repository via FUSE |
-U |
Unmount the borg repository |
Work backup options (thwapback work [ARGS])
| Flag |
Description |
-c <file> |
Use an alternative configuration file |
-M |
Mount the rdiff-backup repository via FUSE |
-U |
Unmount the rdiff-backup repository |
Examples
# Perform a full backup with rotation and a daily tag
thwapback full -Rd
# Mount the borg repository for inspection
thwapback full -M
# Unmount the borg repository
thwapback full -U
# Perform a work backup (rdiff-backup)
thwapback work
# Mount the rdiff-backup repository
thwapback work -M
Configuration
The script sources ~/.config/thwap/thwapback.conf if it exists. You can override the following variables in that file:
| Variable |
Default |
Description |
BORG_CMD |
borgbackup |
Command for borgbackup |
BORG_FS_CMD |
borgfs |
Command for borgfs |
BORG_TGT_BASE |
/srv/backup/borg |
Base directory for borg repositories |
BORG_SRC |
$HOME |
Source directory for full backups |
RDIFF_CMD |
rdiff-backup |
Command for rdiff-backup |
RDIFF_FS_CMD |
rdiff-backup-fs |
Command for rdiff-backup-fs |
RDIFF_TGT_BASE |
/srv/backup/rdiff |
Base directory for rdiff-backup repositories |
RDIFF_SRC |
$HOME/THWAP |
Source directory for work backups |
NOTIFY_HOST |
10.24.10.22 |
Host for 9P notifications |
Notifications
If the 9p command is available and NOTIFY_HOST is reachable, the script will send a success or failure notification after each backup operation.
License
This script is provided as‑is. Use at your own risk.