Skip to content

Rollback

Mikhail Deynekin edited this page Oct 12, 2026 · 2 revisions

Откат прогона

Rollback

Rollback

sr rollback # newest session sr rollback latest sr rollback 9f3a1c # unique id suffix sr rollback 20260131T120530Z-9f3a1c sr rollback 2 # the second newest (ordinal) sr rollback latest --dry-run # show what would be restored sr rollback latest --file src/app.py sr rollback latest --force --yes # unattended, overwrite drifted files

How a session is referenced

full id → unique suffix → ordinal (1 = newest) → latest. Ambiguous suffixes are reported with the candidate list instead of guessing.

Drift detection

For every file the manifest stores the SHA-256 of the content after the run. Before restoring, sr hashes the current file:

  • unchanged → restored silently
  • changed → reported as drifted and SKIPPED, unless --force
  • missing → restored (the session recreates the directory)

That is what makes rollback safe to run hours later: it will not silently throw away edits you made in the meantime.

The rollback is itself reversible

Unless --no-safety-snapshot is given, sr records the pre-rollback content in a new session of kind rollback. So:

sr rollback # oops, wrong session sr sessions # the top entry is the safety snapshot sr rollback # back to the state before the rollback

Renames recorded in the session are undone in reverse order (deepest first), so renaming a directory back cannot be blocked by its own children.

Exit codes

0 everything restored 4 at least one file could not be restored (permissions, missing blob)

Rollback refuses to touch paths outside the session root, paths containing control characters, and anything under /proc, /sys or /dev.


Страница сгенерирована из встроенной справки sr 7.0.1 (sr help <topic>). Первоисточник — sr/help_system.py; он же питает man sr и sr help --all. Если страница и вывод sr help расходятся, верить нужно sr help: он всегда соответствует установленной версии.

Clone this wiki locally