This script provides a unified CLI for running full (borgbackup) or work (rdiff-backup) backups, with automatic target path generation using hashed identifiers, support for tagged backups (hourly, daily, etc.), mount/unmount via FUSE, and optional success/failure notifications to a remote host.
  • Lua 55.1%
  • Shell 44.9%
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
2026-06-22 22:31:47 -07:00
.gitignore chore: add vim backup files to gitignore 2026-06-02 11:16:00 -07:00
LICENSE feat: add MIT license file for project attribution 2026-06-04 06:04:07 -07:00
README.md docs: update README to describe backup storage and recovery structure 2026-06-04 06:02:54 -07:00
thwapback.lua feat: add thwapback backup script with borg and rdiff support 2026-06-22 22:31:47 -07:00
thwapback.sh feat: add borg info and list commands to thwapback script 2026-06-22 22:31:35 -07:00

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

  1. Place thwapback.sh somewhere in your PATH (e.g., ~/bin/thwapback).
  2. Make it executable:
    chmod +x ~/bin/thwapback
    
  3. (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 oneoff
-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 asis. Use at your own risk.