Skip to main content

Module backup

Module backup 

Source
Expand description

Backup session management for undo safety net.

size-waiver: accepted single-domain bulk (policy #1408). Session create, path sanitization, list/restore/prune, and host restore helper are one unit; tests co-located. Do not split for LOC alone (#1494 restore API).

Before any --apply write, commands save the original content of each affected file to .patchloom/backups/<timestamp>/. The patchloom undo command restores the most recent (or a chosen) backup.

Structs§

BackupSession
An active backup session that collects originals before writes.
ListSessionsOptions
Options for list_sessions_under (#1688).
Manifest
The manifest for a backup session.
ManifestEntry
A single file entry in the backup manifest.
SessionListing
One backup root plus its sessions (newest first), for nested monorepo layouts (#1688).

Enums§

FileAction
What the apply operation did to a file.

Constants§

BACKUP_DIR
Directory name under the project root.

Functions§

backup_write_files
Back up files, write new content atomically, and finalize the backup session. All originals are saved before any writes begin, ensuring consistency.
find_backup_roots
Walk path and its parent directories for roots that contain .patchloom/backups.
is_under_backup_dir
True when path is inside a .patchloom/backups tree (any ancestor).
list_sessions
List available backup sessions, most recent first.
list_sessions_under
List backup sessions under project_root, optionally walking nested crates.
prune_old_backups
Prune backup sessions older than 7 days.
refuse_user_write_under_backup_dir
Refuse a user write whose destination is under BACKUP_DIR.
remove_session
Remove a consumed backup session directory so subsequent undo calls reach older sessions instead of replaying the same one.
restore_path_from_latest_backup
Restore a single path from the most recent backup session that contains it.
restore_path_from_session
Restore one path from a specific backup session (exact path match only).
restore_path_from_session_with_guard
Like restore_path_from_session, with optional PathGuard.
restore_session
Restore a specific backup session, returning the number of files restored.
restore_session_with_guard
Restore a backup session, refusing targets outside guard when set.