← Alex Tryshchenko / Projects View on GitHub

Side work / btpair

You don’t need a NAS for backups.

Two external drives and your Mac are enough. Plug in the replica and btpair mirrors your main drive onto it: one way, with the main drive locked read-only and a record of every run on both drives.

Free and MIT-licensed. A terminal app for macOS; needs rsync 3.1 or newer from Homebrew.

  • 0servers, boxes or subscriptions
  • 1 waymain → replica, never back
  • 25%default cap on what one run may delete
  • 110tests, run against real rsync

01 / The idea

rsync can already do this. One wrong flag and it wipes your backup.

Mirroring a drive is one rsync --delete away. Point it the wrong way, run it against an empty drive that failed to mount, or let it delete a folder you only renamed, and the copy you were relying on is gone. btpair wraps rsync with the checks you would forget at 11 pm.

A script you wrote once

  • Source and destination are just paths you typed
  • An empty or unmounted source mirrors as “delete everything”
  • Deleted and overwritten files are gone for good
  • A renamed 200 GB folder is copied again in full
  • Did last week’s run finish? No idea.

btpair

  • Drives know their own role and partner, by volume UUID
  • Refuses to sync from an empty main or to delete more than a set share
  • Everything the replica would lose moves to a trash folder
  • Renames are detected and done on the replica in seconds
  • Every run, its errors and anything pending are written to both drives

02 / How it works

Four steps, the same every time.

Plug in the drives and open btpair. It finds the pair on its own and walks you through the run.

  1. 01

    Pair

    Press n with two drives plugged in. btpair writes a small .backuptool/ folder to each with the pair ID, the drive’s role and its partner’s volume UUID. From then on it recognises main and replica by themselves; drive names don’t matter.

    • identity.json on both drives
    • Cloned metadata blocks the pair
    • Two mains block the pair
  2. 02

    Plan

    Pick the extra steps for this run. Each one checks first whether it has anything to do, so you see “up to date” before you start. A dry run lists every file that would be copied or removed and writes nothing.

    • Dry run
    • Verify by checksum
    • Allow large deletions
  3. 03

    Mirror

    The main drive is remounted read-only and checked before rsync starts. btpair measures the work with a dry pass, applies any renames it found, then mirrors. Anything deleted or overwritten on the replica moves to a trash folder for that run.

    • rsync -aHX --delete
    • Main locked read-only
    • Replica changes go to trash
  4. 04

    Record

    Status, stats, errors and anything left pending are written to both drives. Plug them into any Mac later and btpair knows when they last synced and how it went.

    • state.json
    • runs/<id>.json
    • Full log per run

03 / Safety

Built not to lose your data.

Each guarantee is enforced in code and pinned by a test that runs real rsync against temporary folders acting as drives.

The main drive is read-only

Before copying, btpair remounts the main drive read-only with diskutil and verifies it. A sync never modifies the main drive, and a test checks exactly that.

Nothing is deleted outright

Files removed or overwritten on the replica move to .backuptool/trash/<run>/ with their paths intact, so you can copy them back. The last five runs that deleted something are kept.

Trash only borrows space

When a sync needs more room than is free, the oldest runs’ trash is emptied first, only as much as needed, and each emptied run is logged. A dry run says what it would empty.

Suspicious runs stop early

An empty main drive, a replica short on space, or a run that would delete more than 25% of the replica’s files or of its data all stop before anything changes.

Interruptions are visible

Both drives are marked in_progress before anything changes, so a run that died midway is flagged and completed next time. Cancelling leaves no partial files.

Renames aren’t copies

A file pair counts as a rename only with the same size, the same modification time, one unambiguous match and agreeing content samples. Anything doubtful is copied as before.

04 / Screens

What it looks like.

A live phase timeline, progress with speed and ETA, free space on both drives, and errors one tab away.

05 / Under the hood

The drives remember, not the laptop.

All metadata lives in a plain-JSON folder at the root of each drive and is never copied between them. Any Mac you plug them into can tell which drive is which and how the last run went.

  • Go and rsync. The terminal UI is built with Bubble Tea and Lip Gloss. The copying is done by Homebrew rsync (3.1 or newer) with -aHX --delete; tests pin the direction and that excluded files are never deleted.
  • Extra steps before the mirror. Steps run against the main drive first, so their output reaches the replica too. Write one as a shell command in the config, with a skip_if check and simple ::progress lines, or in Go. A failed step is recorded as pending and offered again next run.
  • Apple Photos, done carefully. A bundled step copies your Photos library to the main drive, but only after checking, file by file, that every original is really on this Mac and not just listed by iCloud. If any are missing, the previous copy stays untouched.
  • Real-drive quirks handled. exFAT stores coarser timestamps and macOS sprinkles ._ files on it; Finder-locked files on the replica are unlocked before they are replaced.
  • Tested like it matters. make check runs gofmt, vet and the whole suite under the race detector, and CI runs the same on macOS. Every screen of the UI is tested to fit 80 to 200 columns.

06 / Get started

Up and running in a minute.

No spare drives handy? make debug && make dev builds folders that act like drives, so you can try everything safely.

# macOS ships an old rsync; btpair needs 3.1+
brew install rsync

git clone https://github.com/tryshchenko/btpair.git
cd btpair
make build
./bin/btpair

The best backup is the one you actually run.

Two drives, one keypress, and a record of how it went.

btpair on GitHub