borg-backup-ui icon indicating copy to clipboard operation
borg-backup-ui copied to clipboard

Scope repository check state to the actual repository after a job switch

Open borg-codex-bot opened this issue 2 months ago • 1 comments

Changing an existing job to a different repository keeps its previous check flag. The next backup can therefore skip the repository integrity check based on a successful check of the old repository and report that old result for the new repository.

Related implementation PR: #494. Additional finding from the 2026-09-10 external acceptance test of #486 on Unraid 7.3.2, test-channel version 2026.09.09.1010.

Evidence

  • At 11:29, the test job backed up to repository 1 and successfully ran its repository check at 11:29:46.
  • The same job ID was then assigned to a newly created repository 2. The 11:39 backup to repository 2 succeeded.
  • That run logged Borg check skipped (last check 0 days ago, interval: 30 days).
  • Its status file reported repository_check_date: 2026-09-10 11:29:46 and repository_check_status: ok, even though the recorded check was performed against repository 1.
  • The wizard retains cache_subdir and check_flag_name when the repository changes. The runner constructs BORG_CHECK_FLAG_FILE from those job-level values; BorgRunner.check() uses the flag's age without verifying the repository identity.

Reproduction

  1. Create a test job assigned to test repository 1 and run a successful backup including its repository check.
  2. Change the same job to a different, newly created test repository 2 while retaining its job ID.
  3. Run a backup before the configured check interval has expired.
  4. Observe that repository 2 inherits repository 1's check timestamp and skips its check.

Required behavior and acceptance

  • A repository-check marker/result must only apply to the repository actually checked.
  • On a job repository change, do not use the previous repository's check timestamp to skip a check or report success for the new repository.
  • Preserve existing check intervals and valid results when a job is merely renamed or saved without changing its repository.
  • Keep unrelated jobs, repository data and valid old-repository state intact; do not clear all Borg caches as a workaround.
  • Cover repository 1 -> repository 2 -> repository 1, unchanged repository, and job rename in focused tests, then repeat the external test.
  • Keep the correction limited to check-state ownership and its displayed/written results. Choose the smallest implementation that enforces the repository boundary.

Scope boundary

The backup itself succeeded; this finding concerns the integrity-check decision and reported evidence. Do not redesign restore-test scheduling or policies, add repository history, move archives, or add the separate repository-change confirmation feature from #452. The stale archive list and file-browser error handling are tracked separately.

Relevant code: api/wizard_api.py, api/wizard_runner.py and runtime/lib/borg_runner.py:BorgRunner.check, including status output derived from the check flag.

User impact: a new repository must not appear checked based on a check of another repository. Release note required. This issue is open work for PR #494, not a completed fix.

borg-codex-bot avatar Sep 10 '26 13:09 borg-codex-bot

Implemented in 366ebb4: new jobs and jobs whose repository assignment changes use a repository-qualified check marker. Unchanged jobs and renames retain their existing marker and interval. Cache directories and old markers remain intact. Returning to a repository with only a legacy marker can cause one fresh check; subsequent switches reuse the corresponding repository's own marker.

Verification: 19 identity/integration tests passed, including repository 1 -> repository 2 -> repository 1, preserving old marker contents/mtime, unchanged jobs, renames, and the check status written by the runner. The local Borg 1.4.5 check also succeeded against two separate test repositories using separate markers.

Retest: run a successful backup/check in test repository 1, change the same test job to a newly created test repository 2, and run it again within the check interval. Repository 2 must perform its own check and must not report repository 1's earlier check timestamp. Then switch back and repeat.

Included in PR #494, test-channel version 2026.09.10.1549. Final source: 366ebb4f448d2c19bbe50636310926e28b11278b. The final pushed commit passed the full preflight once: 935 tests passed, none skipped, plus Python syntax checks.

Test-channel manifest. Existing migrated test installations can update directly; these fixes add no new migration. Keep this issue open pending the external retest and PR acceptance.

borg-codex-bot avatar Sep 10 '26 13:09 borg-codex-bot