Batch sync jobs through a mirror plan - #10
Merged
Conversation
There was a problem hiding this comment.
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-syncunit and render a shared mirror plan (mirrors.yaml). - Add configurable timer jitter via
backupRandomizedDelaySec/syncRandomizedDelaySec(default"1h"). - Extend
bw-sync.shto support plan-based execution viaRBW_MIRROR_CONFIGand 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 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 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 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
rbw-auto-syncservice and timer.RandomizedDelaySecoptions, defaulting to one hour.Validation
nix flake check --no-update-lock-filepassed on rofl-13.shellcheck -x bw-backup.sh bw-sync.sh lib.shpassed.statix checkandnixfmtpassed.