|
| 1 | +<p align="center"> |
| 2 | + <img src="docs/images/icon.png" width="96" alt="MacBackup icon"> |
| 3 | +</p> |
| 4 | + |
| 5 | +<h1 align="center">MacBackup</h1> |
| 6 | + |
| 7 | +<p align="center"> |
| 8 | + <b>A disaster-recovery backup for people who build things on their Mac.</b><br> |
| 9 | + Keys, server access, Codex & Claude Code history, every project with its git history —<br> |
| 10 | + compressed, verified byte by byte, and restorable on any Mac with one built-in command. |
| 11 | +</p> |
| 12 | + |
| 13 | +<p align="center"> |
| 14 | + <a href="../../releases/latest">Download</a> · |
| 15 | + <a href="#quick-start">Quick start</a> · |
| 16 | + <a href="#restore-on-a-new-mac">Restore</a> · |
| 17 | + <a href="#macbackup-vs-time-machine">vs Time Machine</a> · |
| 18 | + <a href="#how-it-works">How it works</a> |
| 19 | +</p> |
| 20 | + |
| 21 | +<p align="center"> |
| 22 | + <img src="docs/images/app-overview.png" width="820" alt="MacBackup main window"> |
| 23 | +</p> |
| 24 | + |
| 25 | +--- |
| 26 | + |
| 27 | +## Why |
| 28 | + |
| 29 | +If your laptop dies today, what do you actually lose? |
| 30 | + |
| 31 | +Not your photos — they are in iCloud. Not your apps — they reinstall. What hurts is the stuff that |
| 32 | +**only exists on this one machine**: |
| 33 | + |
| 34 | +- the SSH key that gets you into your production server, and the root password you saved in Keychain; |
| 35 | +- `.env` files with API keys for twenty projects; |
| 36 | +- months of **Codex and Claude Code** sessions, skills, memory and settings; |
| 37 | +- commits you never pushed, branches with no upstream, folders that were never on GitHub at all; |
| 38 | +- the little scripts, login items and dotfiles that make your Mac *yours*. |
| 39 | + |
| 40 | +MacBackup copies exactly that to an external drive — about **150 GB instead of a full 800 GB disk image** — |
| 41 | +and keeps it fresh automatically. |
| 42 | + |
| 43 | +<p align="center"><img src="docs/images/whats-inside.svg" width="900" alt="What goes into the backup"></p> |
| 44 | + |
| 45 | +## Features |
| 46 | + |
| 47 | +- **Smart scope.** Every folder in your home and in `~/Documents` becomes its own archive. AI tools |
| 48 | + (Codex, Claude Code, Claude app, Gemini/Antigravity, Cursor, Grok) are detected and split sensibly — |
| 49 | + Codex sessions per month, Claude Code chats per project. |
| 50 | +- **Leaves out what comes back by itself:** `node_modules`, virtualenvs, build output, caches, large videos |
| 51 | + inside projects (listed in `inventory/skipped-big-media.tsv` so you know exactly what was skipped). |
| 52 | +- **Incremental.** A fingerprint of names, sizes and change dates decides what changed. The first run |
| 53 | + takes about an hour; a weekly run usually takes a few minutes. |
| 54 | +- **Verified, not hoped.** After writing, every archive is decompressed and **every file is SHA-256-checked** |
| 55 | + against the manifest, then up to 25 files per part are compared with the originals on your Mac. |
| 56 | +- **Live databases done right.** SQLite files (bots, apps, Codex history) are copied with SQLite's backup |
| 57 | + API, so you get a consistent snapshot even while the app is writing. |
| 58 | +- **Secrets collected in one place.** All `.env`, `.pem`, tokens and key folders from every project are also |
| 59 | + gathered into `keys/secret-files`; optionally chosen Keychain passwords are exported too. |
| 60 | +- **Restore needs nothing.** Archives are `tar` + `zstd`; macOS's built-in `tar` reads them: |
| 61 | + `tar -xf part.tar.zst -C ~`. |
| 62 | +- **Calm about real life.** Unplug the drive in the middle of a backup — nothing breaks. It pauses, cleans up |
| 63 | + the half-written file next time and continues where it stopped. No alarm notifications; a reminder comes |
| 64 | + only if a backup is overdue for days. |
| 65 | +- **Native Mac app** with a menu-bar icon: progress, speed, time left, what's inside, run history and logs. |
| 66 | + English and Russian. |
| 67 | +- **Agent-friendly.** The drive carries a `README.md` for people and an `AGENTS.md` for AI agents, plus a |
| 68 | + machine-readable `index.json`, per-file manifests and full logs — point Claude Code or Codex at the drive |
| 69 | + and ask it to restore your Mac. |
| 70 | + |
| 71 | +<p align="center"><img src="docs/images/app-running.png" width="820" alt="A backup in progress"></p> |
| 72 | + |
| 73 | +## MacBackup vs Time Machine |
| 74 | + |
| 75 | +They solve different problems, and they work best **together**. |
| 76 | + |
| 77 | +| | Time Machine | MacBackup | |
| 78 | +|---|---|---| |
| 79 | +| What it copies | The whole disk, apps and system included | The work that exists only on this Mac | |
| 80 | +| Size on the drive | ≈ everything you use (often 500 GB – 1 TB) + history | ≈ 15–20% of it (e.g. 150 GB of 813 GB) | |
| 81 | +| Shares a drive with your films | Wants its own volume and space for history | A folder next to anything else | |
| 82 | +| Restore | Whole Mac via Migration Assistant | Any single project, or everything, with `tar` — on any Mac | |
| 83 | +| Needs | Same macOS family, Migration Assistant | Nothing but the built-in `tar` | |
| 84 | +| Proof the copy is good | Trust | Every file re-hashed after every run | |
| 85 | +| Understands dev work | No — copies `node_modules` and caches too; a live database may be caught mid-write | Skips rebuildable junk, snapshots live DBs, gathers every secret, reports unpushed git work | |
| 86 | +| Readable without the app | Only through Time Machine | Plain archives + manifests + `README.md` / `AGENTS.md` | |
| 87 | +| History of old versions | Yes (hourly/daily/weekly) | Latest version of each part | |
| 88 | + |
| 89 | +**Recommendation:** use Time Machine on a dedicated drive if you can, for the full-system safety net and file |
| 90 | +history. Use MacBackup for the irreplaceable work — it fits on the drive you already carry, and it's the one |
| 91 | +you'll actually be able to restore from on a borrowed Mac in an hour. |
| 92 | + |
| 93 | +## How it works |
| 94 | + |
| 95 | +<p align="center"><img src="docs/images/how-it-works.svg" width="900" alt="How a backup run works"></p> |
| 96 | + |
| 97 | +<details> |
| 98 | +<summary><b>Why zstd -9 (measured)</b></summary> |
| 99 | + |
| 100 | +700 MB samples on an M1 Max: |
| 101 | + |
| 102 | +| codec | ratio on code / chats | speed | |
| 103 | +|---|---|---| |
| 104 | +| zstd -3 | ×1.49 | 1460 MB/s | |
| 105 | +| **zstd -9 --long=27** | **×1.59** | **360–440 MB/s** | |
| 106 | +| zstd -15 --long=27 | ×1.61 | 65–130 MB/s | |
| 107 | +| zstd -19 --long=27 | ×1.64 | 13–15 MB/s | |
| 108 | +| xz -6 | ×1.56 | 22 MB/s | |
| 109 | +| brotli -9 | ×1.58 | 3–11 MB/s | |
| 110 | + |
| 111 | +Level 9 with a long window is within 1–3% of the strongest settings at 15–30× the speed. |
| 112 | +</details> |
| 113 | + |
| 114 | +## Quick start |
| 115 | + |
| 116 | +1. **Install the dependency** (once): `brew install zstd` — Python 3 ships with macOS / Xcode tools. |
| 117 | +2. **Download** `MacBackup.zip` from [Releases](../../releases/latest), unzip, move `MacBackup.app` to |
| 118 | + `/Applications` or `~/Applications`. The app is ad-hoc signed: the first time, right-click → **Open**. |
| 119 | +3. Open **Settings** (⌘,): choose your backup disk, language, and how often to back up (default: every 7 days). |
| 120 | +4. Give MacBackup access to your files: **System Settings → Privacy & Security → Full Disk Access → MacBackup**. |
| 121 | +5. Click **Back up now**. The first run takes a while; after that it's minutes. |
| 122 | + |
| 123 | +To back up automatically, install the scheduler (runs hourly and whenever a disk is connected; it only does |
| 124 | +work when a backup is due): |
| 125 | + |
| 126 | +```bash |
| 127 | +./scripts/install-scheduler.sh |
| 128 | +``` |
| 129 | + |
| 130 | +### Configuration |
| 131 | + |
| 132 | +`~/Library/Application Support/MacBackup/config.json` — the app edits the common keys; the rest is for power users. |
| 133 | +See [`config.example.json`](config.example.json): |
| 134 | + |
| 135 | +| key | meaning | |
| 136 | +|---|---| |
| 137 | +| `disk_volume`, `dest_folder` | where the backup lives, e.g. `/Volumes/Backup` + `MacBackup` | |
| 138 | +| `due_days`, `reminder_grace_days` | back up every N days; remind only after N more days without the disk | |
| 139 | +| `split_dirs` | big folders archived per child (e.g. `Documents/Codex`) | |
| 140 | +| `system_folders` | home folders that are "system" rather than projects (e.g. `Backups`) | |
| 141 | +| `home_skip`, `documents_skip`, `exclude_paths` | things to leave out | |
| 142 | +| `mirror_folders` | folders copied as-is, uncompressed (e.g. course videos you also want to watch from the drive) | |
| 143 | +| `secret_extra_paths` | extra key files/folders to gather into `keys/secret-files` | |
| 144 | +| `keychain_export_regex` | export these Keychain service passwords **with values** (empty = off). Only use on an encrypted drive. | |
| 145 | +| `video_skip_mb` | skip videos larger than this inside projects (default 20) | |
| 146 | + |
| 147 | +### Command line |
| 148 | + |
| 149 | +```bash |
| 150 | +E="python3 MacBackup.app/Contents/Resources/engine/macbackup.py" |
| 151 | +$E plan # what would be backed up, sizes, what changed — writes nothing |
| 152 | +$E run # back up now |
| 153 | +$E verify --all # re-check every archive on the drive |
| 154 | +$E auto # what the scheduler runs |
| 155 | +$E cancel # stop gracefully |
| 156 | +``` |
| 157 | + |
| 158 | +## Restore on a new Mac |
| 159 | + |
| 160 | +Every archive restores into your home folder with the tar that comes with macOS: |
| 161 | + |
| 162 | +```bash |
| 163 | +cd /Volumes/<YourDisk>/MacBackup |
| 164 | +for a in archives/keys/*.tar.zst; do tar -xf "$a" -C ~; done # keys first |
| 165 | +chmod 700 ~/.ssh && chmod 600 ~/.ssh/* |
| 166 | +find archives -name '*.tar.zst' -print0 | xargs -0 -n1 tar -C ~ -xf # or everything |
| 167 | +``` |
| 168 | + |
| 169 | +- Need one file? `grep -l "name" archives/*/*.files.tsv archives/*/*/*.files.tsv` tells you which archive has it. |
| 170 | +- Apps: `inventory/apps.tsv` and `inventory/brew.txt` list what to reinstall. |
| 171 | +- The drive's own [`README.md`](engine/DISK-README.md) walks through it step by step, and |
| 172 | + [`AGENTS.md`](engine/DISK-AGENTS.md) lets an AI agent do it for you. |
| 173 | + |
| 174 | +## Safety |
| 175 | + |
| 176 | +- **Encrypt the backup drive** (Finder → right-click the disk → Encrypt, or format as APFS (Encrypted)). |
| 177 | + Archives themselves are not password-protected, by design: you should never be locked out of your own |
| 178 | + backup by a forgotten second password. The drive's encryption is the lock. |
| 179 | +- Keychain export is **off by default**. When enabled, values go only into the archive on the drive — never into |
| 180 | + logs, the app, or the terminal. |
| 181 | +- Nothing is uploaded anywhere. No network access at all. |
| 182 | + |
| 183 | +## Project layout |
| 184 | + |
| 185 | +``` |
| 186 | +engine/macbackup.py the whole engine (Python 3.9+, stdlib only, + zstd CLI) |
| 187 | +engine/DISK-README.md copied to the drive as README.md (for people) |
| 188 | +engine/DISK-AGENTS.md copied to the drive as AGENTS.md (for AI agents) |
| 189 | +app/ SwiftUI app (Swift Package) — build with app/build.sh |
| 190 | +scripts/ scheduler install/uninstall |
| 191 | +docs/images/ pictures for this README |
| 192 | +``` |
| 193 | + |
| 194 | +Data on your Mac: `~/Library/Application Support/MacBackup/` (`config.json`, `state/`, `logs/`). |
| 195 | +Logs are JSON lines (`logs/runs.jsonl`) plus a human-readable log per run, mirrored to the drive. |
| 196 | + |
| 197 | +## Build from source |
| 198 | + |
| 199 | +```bash |
| 200 | +git clone https://github.com/Lemelson/MacBackup && cd MacBackup |
| 201 | +./app/build.sh # builds and installs ~/Applications/MacBackup.app (bundles the engine) |
| 202 | +``` |
| 203 | + |
| 204 | +Requires Xcode command line tools (Swift 5.10+), macOS 14+. |
| 205 | + |
| 206 | +## License |
| 207 | + |
| 208 | +MIT — see [LICENSE](LICENSE). |
0 commit comments