dcg

BorgBackup

backup.borg

Protects against destructive borg operations like delete, prune, compact, and recreate.

  • 5blocking rules
  • 7safe patterns
  • 1Critical
  • 2High
  • 2Medium
~/.config/dcg/config.toml
[packs]
enabled = ["backup.borg"]

Evaluated when a command contains borg.

Blocking rules

Each rule ID is backup.borg:<name>. Use it in allowlists and [policy.rules].

  1. borg-delete

    Critical

    borg delete removes archives or entire repositories.

    Explanation
    Deleting borg archives or repositories permanently removes backup data. Without the archive, you cannot restore files to that point in time. If you delete the entire repository, all backup history is lost and cannot be recovered. Safer alternatives: - borg list: Review archives before deletion - borg info: Check archive details and size - borg export-tar: Export archive contents before deletion - Use --dry-run to preview what would be deleted
  2. borg-prune

    High

    borg prune removes archives based on retention rules.

    Explanation
    Pruning removes archives that don't match retention rules. Misconfigured retention policies can delete more archives than intended. Once pruned, those backup points cannot be restored. Space is not reclaimed until borg compact is run. Safer alternatives: - borg prune --dry-run: Preview which archives would be removed - borg list: Review current archives before pruning - Double-check retention flags (--keep-daily, --keep-weekly, etc.)
  3. borg-recreate

    High

    borg recreate can drop data from archives.

    Explanation
    Recreate modifies existing archives by recompressing or excluding files. Using --exclude or --exclude-from can permanently remove files from the archive. The original archive state cannot be recovered after recreation completes. Safer alternatives: - borg recreate --dry-run: Preview changes without applying - borg create: Create a new archive instead of modifying existing - borg export-tar: Export archive before recreation for backup
  4. borg-break-lock

    Medium

    borg break-lock forces removal of repository locks.

    Explanation
    Breaking locks removes lock files that protect against concurrent access. If another borg process is actually running (not a stale lock), breaking the lock can cause repository corruption. Only use when certain no other operation is in progress. Safer alternatives: - Check for running borg processes (ps aux | grep borg) - Wait for existing operations to complete - Verify lock is stale (check lock file timestamp)
  5. borg-compact

    Medium

    borg compact reclaims space after deletions.

    Explanation
    Compacting permanently removes data segments that are no longer referenced after delete or prune operations. Before compacting, deleted data could theoretically be recovered. After compacting, the data is permanently gone and disk space is reclaimed. Safer alternatives: - borg list: Verify intended archives still exist - borg check: Verify repository integrity before compacting - Ensure all pruning was intentional before compacting

Safe patterns

Checked first. A command that matches one is never blocked by this pack.

  • borg-list
  • borg-info
  • borg-diff
  • borg-check
  • borg-create
  • borg-extract
  • borg-mount