Bug: Job retention is applied across all archives in a shared repository
Description
Several backup jobs write to the same Borg repository. Each job has separate source paths, a distinct archive-name prefix, and its own configured retention policy.
Example archive prefixes:
backup-backup-*fotos-backup-*nas-backup-*paperless-backup-*unraid_flash-backup-*
All jobs currently use a retention policy of 7 daily / 4 weekly / 6 monthly / 3 yearly.
The automatic prune operation after a job completes does not restrict its selection to archives belonging to that job. Instead, it evaluates all archives in the shared repository using the retention configuration of the job that just ran.
Example
After the NAS job created nas-backup-2026-08-28_11-12-56, the maintenance phase reported:
Repository contains 4 normal archives and 0 checkpoint archives.
Keeping 3 archives and 0 checkpoints, pruning 1 archives and 0 checkpoints.
Keeping archive (rule: daily #1): nas-backup-2026-08-28_11-12-56
Pruning archive (1/1): backup-backup-2026-08-28_08-55-17
backup-backup-2026-08-28_08-55-17 was created by a separate job but was selected for deletion by the NAS job's prune run.
Expected Behavior
Retention must be scoped to archives created by the current job. A job-specific archive prefix is already used when creating archives and should also be used for prune.
For example, the Fotos job should effectively run:
borg prune \
--glob-archives 'fotos-backup-*' \
--keep-daily 7 \
--keep-weekly 4 \
--keep-monthly 6 \
--keep-yearly 3 \
ssh://.../unraid-backup
A dry run with this filter only evaluates the appropriate archive:
Keeping archive (rule: daily #1): fotos-backup-2026-08-28_12-05-41
Actual Behavior
The automatic prune command has no archive-name filter. As a result, one job's completion can prune valid archives belonging to any other job using the same repository.
Suggested Fix
Derive the current job's archive prefix and add an archive filter to automatic prune, for example:
--glob-archives '<job-archive-prefix>-*'
Documented resolution for the shared-repository prune issue.
Implemented in PR #434:
- Job-driven Borg prune now uses the current job archive prefix, for example
photos-backup-*. - Manual repository prune now shows the retention source, archive filter, and retention values before starting.
- Repositories used by multiple jobs require an explicit retention source selection before prune starts.
- The backend validates that the selected retention source job really belongs to the repository.
- Prune logs now state whether retention is scoped to an archive filter or applied repository-wide.
Tested in test-channel version 2026.08.28.1719.
Thanks again for the report. This was an important safety fix for shared Borg repositories.