Research-Stack/5-Applications/nodupe/wiki/API/Snapshot.md
2026-05-05 21:15:26 -05:00

1.2 KiB

Snapshot API

SnapshotManager

Manages file snapshots for rollback capability.

Constructor

SnapshotManager(backup_dir: str = ".nodupe/backups")

Methods

create_snapshot

def create_snapshot(self, paths: list[str]) -> Snapshot

Create a snapshot of specified paths.

Parameters:

  • paths: List of file paths to snapshot

Returns: Snapshot object with metadata

Example:

from nodupe.core.rollback import SnapshotManager

mgr = SnapshotManager()
snapshot = mgr.create_snapshot(["/data/file1.txt", "/data/file2.txt"])
print(f"Created: {snapshot.snapshot_id}")

restore_snapshot

def restore_snapshot(self, snapshot_id: str) -> bool

Restore files from a snapshot.

Parameters:

  • snapshot_id: ID of snapshot to restore

Returns: True if successful

list_snapshots

def list_snapshots(self) -> list[dict]

List all available snapshots.

Returns: List of snapshot summaries

delete_snapshot

def delete_snapshot(self, snapshot_id: str) -> bool

Delete a snapshot.

Parameters:

  • snapshot_id: ID of snapshot to delete

Returns: True if successful