borg-backup-ui icon indicating copy to clipboard operation
borg-backup-ui copied to clipboard

Fix automatic database dump cleanup on Btrfs

Open borg-codex-bot opened this issue 1 month ago • 0 comments

Problem

Automatic removal of database dumps after successful archiving/readback fails on an Unraid Btrfs cache pool with Directory not empty. All PostgreSQL dump files remain; cleanup aborts before MariaDB is processed. Borg create exits 0 and readback verification succeeds, but the job is marked failed and later maintenance is skipped. The second profile still shows Dump created because its archived manifest was not persisted before the first cleanup failed.

Cause and implementation

  • Export retains a directory descriptor opened before dump creation. Btrfs directory enumeration can retain the entry boundary from that open; reusing it for cleanup can miss the newly created files.
  • Enumerate through a freshly opened descriptor relative to the pinned run directory. Preserve path replacement, symlink, hardlink and unknown-file guards; never use recursive deletion.
  • Persist verified archive manifests for all profiles before starting any cleanup.
  • Log automatic cleanup start, completion and failure distinctly from export/archive verification.
  • Add regression coverage for stale directory enumeration and multiple-profile cleanup failure, plus update user-facing release notes.

Acceptance

An after_archive job removes only its verified current-run dumps on Btrfs. Manual retention and warning/failure behavior remain unchanged. A cleanup failure preserves accurate archive status for all verified profiles and is identifiable in the log. Existing historical dumps are not automatically removed.

User-visible bug fix; release note required. Publish a verified test candidate for the maintainer's Btrfs test before stable promotion.

borg-codex-bot avatar Nov 03 '26 11:11 borg-codex-bot