Skip to content

Batch sync jobs through a mirror plan - #10

Merged
pschmitt merged 2 commits into
mainfrom
agent/batched-mirror-sync
Aug 14, 2026
Merged

Batch sync jobs through a mirror plan#10
pschmitt merged 2 commits into
mainfrom
agent/batched-mirror-sync

Conversation

@pschmitt

Copy link
Copy Markdown
Owner

Summary

  • Batch enabled NixOS sync jobs into one rbw-auto-sync service and timer.
  • Render a declarative mirror plan and prepare shared rbw accounts once.
  • Add configurable RandomizedDelaySec options, defaulting to one hour.
  • Update the rbw flake input to the declarative mirror implementation.

Validation

  • nix flake check --no-update-lock-file passed on rofl-13.
  • shellcheck -x bw-backup.sh bw-sync.sh lib.sh passed.
  • statix check and nixfmt passed.
  • End-to-end sync passed on rofl-10.

@pschmitt
pschmitt marked this pull request as ready for review August 14, 2026 10:57
Copilot AI lite review requested due to automatic review settings August 14, 2026 10:58
@pschmitt
pschmitt merged commit f7ef30e into main Aug 14, 2026
3 checks passed
@pschmitt
pschmitt deleted the agent/batched-mirror-sync branch August 14, 2026 10:58

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refactors the NixOS module to batch all enabled sync jobs into a single rbw-auto-sync systemd service/timer by rendering a declarative rbw mirror --config plan, aiming to prevent rbw-agent startup races and reduce repeated account preparation.

Changes:

  • Batch enabled sync jobs into one rbw-auto-sync unit and render a shared mirror plan (mirrors.yaml).
  • Add configurable timer jitter via backupRandomizedDelaySec / syncRandomizedDelaySec (default "1h").
  • Extend bw-sync.sh to support plan-based execution via RBW_MIRROR_CONFIG and shared account preparation.

Reviewed changes

Copilot reviewed 3 out of 4 changed files in this pull request and generated 3 comments.

File Description
README.md Updates NixOS module documentation to reflect new batched sync design and timer jitter options.
nix/module.nix Implements mirror-plan rendering, batches sync units, introduces randomized delay options, and refactors sync env wiring.
flake.lock Updates the rbw input revision/hash.
bw-sync.sh Adds plan-based sync path, shared account preparation, and multi-LAST_SYNC writing.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread bw-sync.sh
Comment on lines +133 to +137
local credential_vars
credential_vars=$(lookup_sync_credentials "$account") || return 1
IFS=':' read -r password_var totp_var <<< "$credential_vars"
password="${!password_var:-}"
totp="${!totp_var:-}"
Comment thread nix/module.nix
Comment on lines +594 to +597
{
assertion = lib.length syncPeriodValues <= 1;
message = "services.rbw-auto.syncJobs: all enabled jobs must use the same period when batched into one systemd timer";
}
Comment thread README.md
Comment on lines +142 to +147
Backup jobs remain independent named service/timer pairs. Enabled sync jobs
are instead rendered into one declarative `rbw mirror --config` plan and run
sequentially by the single `rbw-auto-sync` service/timer, avoiding startup
races between jobs sharing an rbw account. Sync jobs must use the same
`period`; their individual `workDir` markers and Monit checks remain
independent. Both job kinds share one system user/group and one
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.

2 participants