Skip to content

feat: select and bulk delete backups, and keep them by count, size or age - #22

Merged
RealDoc06 merged 7 commits into
mainfrom
feat/backup-retention
Nov 17, 2026
Merged

RealDoc06 merged 7 commits into
mainfrom
feat/backup-retention

Conversation

@RealDoc06

@RealDoc06 RealDoc06 commented Nov 17, 2026 •

Copy link
Copy Markdown
Owner

Backups piled up with no way to clean them up except one Delete at a time, and the server always kept a hardcoded 10. Now you can select backups and delete them together, and set a retention rule per server: keep the last N, up to X GB in total, up to N days old. Past any limit the oldest BeaconSync backups go first and the newest always stays. Backups written by mods like FTB Backups are left to the mod.

  • The rule lives on the server in .beacon/backup-retention.json. It's left out of backups, so restoring an old backup doesn't bring back an old rule. It applies after every new backup, when the agent starts and when it's saved. The default is the old "last 10", so nothing changes until you set one.
  • Saving a rule that would delete backups asks first ("Delete 5 backups now? 3.6 GB"). Invalid limits get a red border; the hub also rejects zero limits.
  • CLI: beacon server backups keep --last 5 --max-gb 5 --max-days 10, and beacon server backups shows the current rule.
  • Older agents can't read the new action, so the app only shows the retention row once the server reports a rule, and the hub refuses it otherwise. The hub keeps this in memory, so it now asks the agent to send its backups and rule again after a hub restart (before, the backup list stayed empty until the server's next action).
  • Deploy order: the hub at beaconsync.realdoc06.it needs this build before the app can save rules; servers pick it up with "Update beacon".

Tested end to end in the dev app against a local hub and a local agent (not production): bulk deleting 2 rows removed exactly those 2 archives; saving 2 GB / 5 days asked to delete 3 and the agent pruned exactly those 3; restarting the hub brought the backup list and rule back in about 40 s without touching the agent. New tests cover the pruning rule, the rule surviving a restore, and the hub's old-agent, zero-limit and resync handling.

Screenshots (Backups tab, macOS dev app)

Before After
Selected Bulk delete Rule would delete backups After saving 2 GB / 5 days

Council review

Rounds: 4

Delegate Round 1 Round 2 Round 3 Round 4
Claude Opus 8.5/10 9/10 9.5/10 9.5/10
Muse Wonder 8/10 9/10 9/10 10/10

Created with Claude Opus 5.5 in Claude Code (T3 Code). Reviewed by Claude Opus 5.5 and Muse Wonder 1.0.

Summary by CodeRabbit

  • New Features

    • Configure server backup retention by count, total size, or age in the app or CLI. Retention changes can prune older backups, while the newest backup is kept.
    • Select and delete multiple backups, with selected backup count and total size shown in the app.
    • Backup listings show the configured retention policy when available.
  • Documentation

    • Added guidance and examples for setting backup retention limits.

@coderabbitai

coderabbitai Bot commented Nov 17, 2026 •

Copy link
Copy Markdown

Explain Change →

Caution

Review failed

The pull request is closed.

Walkthrough

The pull request adds per-server backup retention limits by count, total size, or age. It stores and applies those limits on the server, relays retention state through the hub, and adds configuration controls to the CLI and desktop app.

Changes: Backup retention

Layer / File(s) Summary
Retention contract and hub relay
crates/core/src/api.rs, crates/hub/src/routes.rs, crates/hub/src/tests.rs, apps/desktop/src/lib/types.ts
The API adds retention data and actions. The hub reports agent state, requests resynchronization when backups have not been reported, and validates retention actions. Tests cover resynchronization and retention action relaying.
Persisted rules and backup pruning
crates/cli/src/backups.rs, crates/cli/src/server.rs
The CLI stores retention rules separately from backups and prunes according to count, size, and age limits. Startup pruning and tests cover configured limits, immediate pruning, and restore behavior.
CLI configuration and agent synchronization
crates/cli/src/server.rs, crates/cli/src/tui.rs, README.md, docs/ARCHITECTURE.md
The CLI adds the keep command and handles retention actions. Agent state reports retention, polling can trigger a state resync, and backup listings show the configured policy. The documentation describes the command and retention behavior.
Desktop backup and retention controls
apps/desktop/src/lib/types.ts, apps/desktop/src/views/pack/ServerPanel.tsx
The desktop app receives retention data, supports selecting and deleting multiple backups, and adds a validated retention editor with confirmation when proposed limits would prune backups.

Estimated code review effort: 4 (Complex) | ~45 minutes

Change: Feature

Sequence Diagram(s)

sequenceDiagram
  participant BackupCmd
  participant Hub
  participant AgentLoop
  participant BackupStore
  BackupCmd->>Hub: Send SetRetention action
  Hub->>AgentLoop: Deliver queued action during polling
  AgentLoop->>BackupStore: Save rule and prune backups
Loading

Possibly related PRs

  • RealDoc06/beaconsync#1: Adds the agent update path that the pull request describes for rolling out agent builds to existing servers.
Merge Risk: Moderate · up to 30d56

Backup retention can occasionally delete the wrong backup, such as the newest one when two finish in the same second. Pruning failures are also not reported, and the app can show an outdated retention rule after a failed upload. These edge cases involve deleting backups, so they should be fixed or consciously accepted before merge.

- [ ] Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@RealDoc06
RealDoc06 merged commit e0ec391 into main Nov 17, 2026
6 of 7 checks passed
@RealDoc06
RealDoc06 deleted the feat/backup-retention branch November 17, 2026 02:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant