Skip to content

Add native restic snapshot backend for encrypted deduplicating workstation backups #3

Description

@CruxExperts

Summary

Add a native restic snapshot backend to bbackup for encrypted, deduplicating workstation backups. This should be first-class bbackup functionality, not a wrapper script around restic.

Motivation

A workstation backup profile needs encrypted deduplicating snapshots, automatic Git repository discovery, retired-repository protection, restore/check workflows, machine-readable output, and scheduler integration. Restic already provides the encrypted deduplicating repository layer; bbackup should own the profile model, discovery, safety rules, scheduling, state ledger, and CLI surface.

Proposed scope

  • Add a native config area such as snapshot_profiles.
  • Add a restic snapshot engine.
  • Add bbackup commands for snapshot init, snapshot run, snapshot check, snapshot restore, snapshot retire, snapshot purge-plan, and snapshot schedule.
  • Support JSON output for planning, runs, health checks, purge plans, and restore/check operations.
  • Support profile-level dependency checks in bbman health, including restic, rclone, remote reachability, password file permissions, cache directory, hostname guard, and repository initialization.
  • Support automatic Git repository discovery from configured repo homes, plus explicitly configured repo roots.
  • Preserve retired/deleted repository snapshots by default; never run broad restic forget across the whole profile repository.
  • Maintain a bbackup state ledger of discovered repos, stable repo IDs/fingerprints, active/retired status, retirement time, and last successful snapshot IDs.
  • Back up each discovered repo as its own restic snapshot with tags such as bbackup, profile=<name>, scope=repo, and repo_id=<id>.
  • Restrict automated retention to active repo IDs and configured non-repo scopes only.
  • Require dry-run-first manual purge planning for retired repos before any destructive forget/prune action.
  • Provide restore and repository check commands suitable for smoke verification and scheduled maintenance.
  • Provide schedule generation/install support, for example user systemd timers that call bbackup directly.
  • Include unit and integration tests for config parsing, command construction, discovery, retired-repo protection, purge safety, hostname guard, dependency health, local restic repo init/backup/check/restore, and path-reuse/fingerprint conflicts.

Acceptance criteria

  1. A native bbackup config can define a restic snapshot profile with repository URL, cache dir, state dir, password file, host ID, repo discovery roots, explicit roots, include paths, exclude paths, retention policy, and scheduling metadata.
  2. CLI commands exist for snapshot init, snapshot run, snapshot check, snapshot restore, snapshot retire, snapshot purge-plan, and snapshot schedule.
  3. Commands support human-readable and JSON output where appropriate.
  4. bbman health reports profile-specific dependency and readiness status.
  5. New Git repos under configured repo homes are included automatically without config edits.
  6. Deleted repos are marked retired and excluded from automated retention when they have at least one successful snapshot.
  7. Deleted repos without any successful snapshot produce a critical alert instead of being silently dropped.
  8. Path reuse with a different Git fingerprint is detected and blocks history merging until manually resolved.
  9. Automated retention never purges retired repos or runs broad profile-wide forget operations.
  10. Manual purge requires a dry-run purge plan and explicit confirmation before destructive restic operations.
  11. Restore and check workflows are covered by integration tests using a temporary local restic repository.
  12. Scheduler generation supports daily backup, weekly maintenance, and monthly verification flows without overlapping runs.

Notes

For workstation backups using a cloud remote such as Google Drive through rclone, restic encryption is sufficient for content and metadata encryption. Additional rclone crypt wrapping should remain optional rather than required by the profile design.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions