Skip to main content

snapback — undo for your machine

snapback run -- <any command>    # cheap snapshot first, then run it
snapback undo                    # didn't like it? put everything back

We hand filesystem access to AI agents, migration scripts, and codemods every day — and the rollback story below "restore the whole VM" is usually nothing. git checkout doesn't cover your SQLite file, your untracked uploads dir, or the Postgres volume your migration just mangled.

snapback is that missing layer: one command to checkpoint the working tree, your databases, and your container volumes — and one command to snap back.

Quickstart

pip install snapback-cli

snapback run -- python migrate.py     # snapshot, then run
snapback undo                         # roll back the tree (and undo is undoable: `snapback redo`)

snapback snap -m "before letting the agent loose"   # manual checkpoint
snapback list                         # what can I go back to?
snapback diff                         # what changed since the last snapshot?
snapback gc --keep 5                  # prune old snapshots

No config needed — by default snapback snapshots the working tree (minus .snapback/ itself). Zero dependencies, Python ≥ 3.11.

Beyond files: databases and volumes

Drop a snapback.toml in the project root to declare extra targets:

[snapshot]
ignore = ["node_modules", "*.log", "app.db"]   # skip in tree snapshots

[[target]]
backend = "sqlite"          # consistent even while the app holds the db open
path = "app.db"             # (uses SQLite's online backup API, not file copy)

[[target]]
backend = "docker-volume"   # tar the named volume via a helper container
volume = "pgdata"

Every snapback run / snap / undo now covers all three: tree + db + volume, atomically bookended around your risky command.

How it works

  • Snapshots live in .snapback/snapshots/<id>/ with a meta.json recording the command, targets, and per-backend payloads.
  • undo restores the newest snapshot — but first it saves the current state as a pre-undo snapshot, so redo gets you back. Undo is never a trap.
  • run passes the wrapped command's exit code through untouched, so it slots into scripts and CI: snapback run -- make deploy-staging.
  • diff [id] shows what changed since a snapshot (A/D/M per path) — check what the agent actually did before deciding whether to undo it.
  • Backends are one file each in snapback/backends/, discovered automatically. snapback backends lists what your install supports.

Storage backends

Backend Status Strategy
copytree ✅ shipped portable file copies; works everywhere, no privileges
sqlite ✅ shipped SQLite online backup API; consistent under live connections
docker-volume ✅ shipped tar via throwaway alpine container
apfs ✅ shipped tmutil localsnapshot on macOS — O(1), copy-on-write; run sudo -v before restore, snapshots auto-purge in ~24 h
btrfs 🙋 help wanted btrfs subvolume snapshot — O(1), copy-on-write
zfs 🙋 help wanted zfs snapshot / zfs rollback
overlayfs 🙋 help wanted run the command in an overlay, commit or discard
postgres 🙋 help wanted pg_dump / restore, or template-database clone
mysql 🙋 help wanted mysqldump / restore
restic 🙋 help wanted dedup'd remote snapshots via restic repo

A backend is one file. It exposes NAME, snapshot(spec, payload_dir, root) -> payload, and restore(spec, payload_dir, root, payload) — see snapback/backends/sqlite_db.py for the shape (60 lines). One backend or one integration per PR; see CONTRIBUTING.md.

Integrations

  • agentbox — agentbox run --checkpoint -- python agent.py takes a snapback snapshot right before the sandboxed agent's first mutating effect and records the checkpoint id in agentbox's hash-chained trace; snapback undo reverts the whole run. Tip: set ignore = ["trace.jsonl"] in snapback.toml so rollback never truncates the audit trail.
  • Your agent framework here — a pre-tool-use hook is ~30 lines (snapshot lazily on the first mutating tool call, surface snapback undo on exit); PRs welcome.

What snapback is not

  • Not a backup tool — snapshots are local, short-lived checkpoints, not disaster recovery. gc them freely.
  • Not filesystem magic by default — the portable backend copies files. Switch the tree target to apfs (or a future btrfs/zfs) for O(1) CoW snapshots.
  • Not a sandbox — the command really runs. snapback makes it reversible, not contained.

License

MIT

Metadata

Release files for snapback-cli 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for snapback-cli 0.2.0
File Size Uploaded Provenance Actions
snapback_cli-0.2.0.tar.gz 20.9 kB With provenance Details for snapback_cli-0.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for snapback-cli 0.2.0
File Interpreter ABI Platform Actions
snapback_cli-0.2.0-py3-none-any.whl Python 3 none any Details for snapback_cli-0.2.0-py3-none-any.whl

Total release size: 37.5 kB

Release files / snapback_cli-0.2.0.tar.gz

Download URL snapback_cli-0.2.0.tar.gz
Size 20.9 kB
Tags Source
SHA-256 checksum
How to use checksums
63c379c62909d78781a9dfecae186801d0ca01e1fe939336304a0b36bf703145
BLAKE2b-256 checksum
How to use checksums
082f7e40d5b4faa6782ed3a24afb6d16030b40b609e4c4eb02eea211ab3be4b7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 9, 2026.

Transparency log

Release files / snapback_cli-0.2.0-py3-none-any.whl

Download URL snapback_cli-0.2.0-py3-none-any.whl
Size 16.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e59e483c9e7919c04a710873ad46b4c7b147514f584197845ccdb4ee4c1b24fd
BLAKE2b-256 checksum
How to use checksums
f71b13a4f0cce37be801004f2e013b7f57013839e199d2cd42990d446d23c193
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 9, 2026.

Transparency log

Security for snapback-cli 0.2.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for snapback_cli-0.2.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 9, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page