backup: refuse an empty archive-prefix list before the off-site prune #608

Stängd
öppnade 2026-10-08 21:12:22 +00:00 av supernaut · 0 kommentarer
Ägare

What

The daily backup prunes old archives on each off-site destination with rclone delete "<dest>:<bucket>/" --min-age 14d plus one --include pair per entry of backup_archive_prefixes (ansible/roles/backup/templates/bitborg-backup.sh.j2:223-228). The rclone delete walks the whole bucket. The Glesys bucket also holds the restic repositories (RESTIC_REPOSITORY in backup.env.j2 uses the same bucket variable).

Why

The --include list is the only guard. With an empty list the loop renders no --include and the delete has no filter.

Failing case

backup_archive_prefixes is [bitborg, gitborg] today, and vars.yml carries a comment about dropping an entry after 2026-10-31. Someone empties the list. The next daily run deletes every object older than 14 days in the bucket, including restic packs. The local find prune also renders an empty \( \) group.

Fix

Add --max-depth 1 to the rclone delete, so the restic prefix is never walked. Add ansible.builtin.assert: backup_archive_prefixes | length > 0 in roles/backup/tasks/main.yml.

Done when

  • rclone delete runs with --max-depth 1.
  • An empty backup_archive_prefixes fails the play before any template is written.
  • Rendered script reviewed for the one-entry and two-entry cases.
## What The daily backup prunes old archives on each off-site destination with `rclone delete "<dest>:<bucket>/" --min-age 14d` plus one `--include` pair per entry of `backup_archive_prefixes` (`ansible/roles/backup/templates/bitborg-backup.sh.j2:223-228`). The rclone delete walks the whole bucket. The Glesys bucket also holds the restic repositories (`RESTIC_REPOSITORY` in `backup.env.j2` uses the same bucket variable). ## Why The `--include` list is the only guard. With an empty list the loop renders no `--include` and the delete has no filter. ## Failing case `backup_archive_prefixes` is `[bitborg, gitborg]` today, and `vars.yml` carries a comment about dropping an entry after 2026-10-31. Someone empties the list. The next daily run deletes every object older than 14 days in the bucket, including restic packs. The local `find` prune also renders an empty `\( \)` group. ## Fix Add `--max-depth 1` to the `rclone delete`, so the restic prefix is never walked. Add `ansible.builtin.assert: backup_archive_prefixes | length > 0` in `roles/backup/tasks/main.yml`. ## Done when - [ ] `rclone delete` runs with `--max-depth 1`. - [ ] An empty `backup_archive_prefixes` fails the play before any template is written. - [ ] Rendered script reviewed for the one-entry and two-entry cases.
Logga in för att delta i denna konversation.
Ingen milstolpe
Inga tilldelade
1 deltagare
Notiser
Förfallodatum
Förfallodatumet är ogiltigt eller utanför gränserna. Använd formatet "åååå-mm-dd".

Inget förfallodatum satt.

Beroenden

Inga beroenden satta

Referens
bitborg/bitborg-infra#608
Ingen beskrivning angiven.