A utility to automatically back up specific drives, when plugged in, using snapshots. Scans /media//mnt (or any other dir) for a specific drive name (using the folder name), and when attached, backs up the drive using Restic. If the drive is unplugged during backup, the backup will be abandoned, but because of Restic's design, this isn't horrible, as the next backup still only needs to back up changed files.
The goal of this project is to be able to plug in the portable SSD that I work off of into my Raspberry Pi and have it automatically back up without me needing to initiate anything. A web UI provides a dashboard to view backup status, logs, and manage backup settings. A SQLite database is used and BetterAuth handles authentication. In addition to configuration, the web UI allows for snapshot management (restore, download, delete).
-
Clone the repository and navigate to the project directory.
a.
git clone https://github.com/slashtechno/autobackb.cd autoback -
Install dependencies (bun is preferred, but npm/pnpm should also work).
a.
bun install -
Copy
.env.exampleto.envand fill in the required environment variables.a.
cp .env.example .env
docker compose pull &∓& docker compose up -dThe container includes Restic and runs migrations automatically on startup. The app runs on port 8433.
git pull &∓& docker compose pull &∓& docker compose up -dMigrations run automatically on startup, so no manual database steps are needed.
The host filesystem is mounted at /host and PUBLIC_HOST_PREFIX=/host is set in compose.yaml. Enter paths as they appear on the host (e.g. /mnt/usb) — the app prepends /host automatically. The UI shows a note when this is active.
To restrict access to specific directories, narrow the volume mount in compose.yaml:
volumes:
- /mnt:/host/mntOr remove PUBLIC_HOST_PREFIX entirely to disable prefix behaviour.
If you're on a CLI-only system, drives may not be automatically mounted when plugged in. Autoback detects drives by watching for the mount-point directory to appear and disappear, so the mount point must not exist when the drive is absent. Do not use fstab or x-systemd.automount — both leave a permanent stub directory at the mount point, which prevents drive detection from working.
Instead, use a udev rule so the OS mounts the drive (and creates the directory) on plug-in, and unmounts it (and removes the directory) on unplug.
sudo ./manage-udev.shThe script provides a simple menu to add and remove rules. It will show you available drives and their UUIDs, then write the udev rules automatically.
-
Find the UUID of your drive:
lsblk -o NAME,SIZE,FSTYPE,UUID,LABEL
-
Create
/etc/udev/rules.d/99-autoback.ruleswith the following, substituting your UUID, mount point, and filesystem type:ACTION=="add", SUBSYSTEM=="block", ENV{ID_FS_UUID}=="YOUR-UUID", RUN+="/usr/bin/systemd-run --no-block /bin/sh -c 'mkdir -p /mnt/backup && mount -t ext4 /dev/disk/by-uuid/YOUR-UUID /mnt/backup'" ACTION=="remove", SUBSYSTEM=="block", ENV{ID_FS_UUID}=="YOUR-UUID", RUN+="/usr/bin/systemd-run --no-block /bin/sh -c 'umount -l /mnt/backup; rmdir /mnt/backup'" ackup'" -
Reload udev rules:
sudo udevadm control --reload-rules
Plug in the drive — it will be mounted automatically. Configure the same path (/mnt/backup in the example) in the Autoback web UI.
Exclude file and snapshot retention
Exclude file — path to a text file listing patterns for restic to skip during backup (one per line). Useful for cache dirs, large temp files, etc. See restic's exclude patterns for syntax. Example entry: /home/user/.cache.
Keep snapshots — maximum number of snapshots to retain per drive. After each successful backup, older snapshots beyond this count are pruned automatically (restic forget --keep-last N --prune). Leave blank to keep all snapshots indefinitely.
Both settings are configured per-drive under the Configure toggle in the web UI.
To show an updating dashboard, generate an API key (it won't expire until you revoke it) in the web UI, edit the variables in scriptlet.sh, then run the script:
bash scriptlet.shThe idea is that you can run this as a scriptlet on a modded Kindle, and have it show backup status in real time on the e-ink screen.