git status for your whole system. unbrick snapshots installed packages,
enabled systemd services, and the hashes (+ content) of config files you
care about, then lets you diff or restore against a saved snapshot — cheap
and fast, with no Btrfs/LVM filesystem snapshotting required.
go install github.com/jolynini/unbrick@latestsudo apt build-dep . # or: sudo mk-build-deps -i debian/control
dpkg-buildpackage -us -uc -b
sudo apt install ../unbrick_*.debThe debian/ packaging builds against Debian's own golang-*-dev packages
(cobra, fatih/color, yaml.v3, and their own transitive dependencies) rather
than a vendored copy, via GO111MODULE=off and a GOPATH that layers this
source over /usr/share/gocode. Plain go build ./... outside of Debian
packaging still uses go.mod/go.sum as normal (fetching over the module
proxy the first time, same as any other Go project).
# Take a baseline snapshot
unbrick save --name baseline
# ... install stuff, edit configs, enable services ...
# See what changed since the last snapshot (vs. current live state)
unbrick diff
# List all snapshots
unbrick list
# Inspect one in full
unbrick show baseline
# Bring the system back to that snapshot (shows a plan first, always)
sudo unbrick restore baseline --dry-run
sudo unbrick restore baselineCaptures:
- Packages — every
dpkg-installed package and its version. - Services — every systemd unit enabled via
systemctl list-unit-files --state=enabled. - Configs — sha256 + mtime (and a compressed copy of the actual
content, so
diff/restorehave something to work with) for every file under the tracked paths in~/.unbrick/config.yaml(default:/etc,~/.bashrc,~/.profile,~/.config).
Snapshots are written to ~/.unbrick/snapshots/<timestamp>[-<label>]/.
File content is deduplicated in a shared object store at
~/.unbrick/objects/, so an unchanged file across many snapshots costs
disk space exactly once. The newest retention_count snapshots (default
10) are kept; older ones are pruned automatically. save never modifies
anything outside ~/.unbrick.
- No arguments: diffs the latest snapshot against current live state.
<snapshot-id>: diffs that snapshot against live state instead.--against <snapshot-id>: diffs two stored snapshots against each other, without touching live state at all.--json: machine-readable output instead of colored text.
Shows three sections: packages added/removed/version-changed, services newly enabled/disabled, and configs added/modified/removed. Always read-only.
Builds a plan (reusing the same diff logic as diff) comparing live state
against the target snapshot, shows it, and only then asks what to do:
- Packages: missing ones are installed pinned to the snapshot's
version; packages present now but absent from the snapshot are listed
and require an explicit yes before removal —
--yesdoes not skip this one confirmation, by design. - Configs: for each changed or missing tracked file, you're prompted
per file —
[r]estore/[s]kip/[d]iff. The live version is always backed up to~/.unbrick/pre-restore-backup/<run-id>/before being overwritten. Files present now but absent from the snapshot are reported but never deleted automatically. - Services: re-enables/disables units to match the snapshot.
--dry-run shows the plan and exits without prompting or changing
anything. Package installs/removals and service changes need root — run
sudo unbrick restore ... (or just unbrick restore --dry-run to review
without root).
Table of every stored snapshot: ID, timestamp, label, and package/service/ config counts.
Full manifest
70A7
contents for one snapshot (--json for the raw manifest).
~/.unbrick/config.yaml, created with defaults on first run:
tracked_paths:
- /etc
- ~/.bashrc
- ~/.profile
- ~/.config
ignore_patterns:
- "*.log"
- "*.sock"
- "*.pid"
- "*/cache/*"
- "*/Cache/*"
retention_count: 10
max_file_size_bytes: 2097152 # 2MBDirectories that get noisy application state under ~/.config (browser
profiles, chat client caches, etc.) will show up as frequent diffs unless
you narrow tracked_paths or add ignore patterns — diff/restore are
only as useful as what you choose to track.
Drop a .unbrickignore file in any tracked directory to exclude paths
under it, gitignore-style (one pattern per line, # for comments, trailing
/ for directory-only matches). This is a practical subset of gitignore
syntax — no negation, no ** — sufficient for excluding cache/log/socket
paths.
- Read-only by default:
save,diff,list, andshownever modify anything outside~/.unbrick. Onlyrestoretouches live system state, and only after showing a plan and getting confirmation. - Fast: package/service capture shells out to
dpkg-queryandsystemctl; config file hashing is parallelized across a worker pool sized toGOMAXPROCS. A snapshot of a typical desktop system (~5k packages, ~4k tracked config files) takes well under a second. - No extra runtime dependencies: everything is driven by
dpkg,apt-get, andsystemctl, which are already present on any Debian/ Ubuntu system. The Go module dependencies (cobra, fatih/color, yaml.v3) are compiled into the single static binary at build time, not fetched at runtime. - Known limitation: pruning old snapshots (
retention_count) does not currently garbage-collect object-store blobs that no remaining snapshot references — deleted snapshots' unique file content is left on disk rather than risking data loss on a prune. Agcsubcommand to reclaim that space is a natural next addition.
go build ./...
go test ./...
gofmt -l .The diff engine (internal/diffengine) is the correctness-critical core —
it has unit test coverage for added/removed/changed packages, services,
and configs, including nil-manifest edge cases (no prior snapshot).