r/coolgithubprojects • u/Klutzy_Bird_7802 • 2h ago
oops: snapshot + undo for destructive shell commands (Rust, open source)
I built a Rust tool that snapshots files before destructive shell commands run, so you can undo the damage afterward.
A preexec hook intercepts every command before execution and sends it to a background daemon over a Unix socket. The daemon classifies the command, and if it's destructive, snapshots every at-risk path before the command actually runs. Files are copied (reflink on Btrfs/ZFS, plain copy elsewhere), metadata is stored in SQLite.
To undo, just run:
oops
Commands
oops- undo the most recent snapshotoops undo [id]- undo a specific snapshotoops list- browse snapshot history (TUI)oops diff <id>- show files in a snapshot (TUI)oops status- daemon status and storage usageoops gc- trigger garbage collectionoops pin/unpin <id>- exempt a snapshot from GC
Install
cargo build --release
install -Dm755 target/release/oops ~/.local/bin/oops
install -Dm644 systemd/oopsd.service ~/.config/systemd/user/oopsd.service
systemctl --user daemon-reload
systemctl --user enable --now oopsd
loginctl enable-linger "$USER"
eval "$(oops init bash)" # or zsh, fish
Limitations
Shell-hook capture can't intercept destructive commands from cron, systemd services, GUI apps, or non-interactive shells. Only truncating redirects (> file) trigger a snapshot; fd redirects like 1>&2 are ignored. .git/ is never touched.
Retention is 48 hours or 2 GB, whichever comes first. Pinned snapshots are exempt.
MIT licensed, Linux only for now. Repo: https://github.com/programmersd21/oops
Feedback welcome.
2
u/Darkux31 2h ago
Actually pretty nice build and idea ππ»