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

Validate USB mounts and report access errors before backup startup

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

USB backup preflight checks only whether the configured mount path is a directory and whether write access is allowed. It does not verify that the path is an actual mount point, and an I/O error is passed to the generic job exception handler.

Related implementation PR: #494. The maintainer requested this correction on the existing job-ID branch.

Reported behavior

A USB drive was physically disconnected without unmounting it. The next scheduled backup reported:

INFO USB mount check enabled: /mnt/disks/<drive>
ERROR Job aborted by exception: [Errno 5] Input/output error: '/mnt/disks/<drive>'
INFO Borg backup failed (exit 2)

The run aborted before borg create. The problem is incomplete mount validation and error classification, not a backup continuing after this error. An existing unmounted directory must not pass the USB preflight either.

Required behavior

  • Confirm that the configured USB mount path is a real mount point, in addition to being a directory and having write access.
  • Preserve the existing skipped outcome for missing/unmounted or non-writable USB targets.
  • Treat mount access errors, including EIO from a disconnected but stale mount, as controlled failures with a clear USB-specific message and failure code. Do not hide genuine I/O errors as normal skips.
  • Stop before Docker/VM changes, Borg create and maintenance. Failure finalization must not query the unavailable repository through Borg either.
  • Persist the reason in the existing log, status and notification paths; retain normal cleanup and resource-lock release.
  • Cover a mounted target, a missing path, an existing unmounted directory, a read-only target and simulated I/O errors. Check that no target data is written and no Borg command is run for rejected targets.

Scope

Keep the fix in PR #494 with its own issue-linked commit and release-note fragment. Do not add automatic mounting, unmounting, filesystem repair, continuous device monitoring, new settings or migrations. A preflight cannot guarantee that a drive remains connected during the subsequent backup; later Borg I/O failures must still fail the run.

User impact: clear USB failure diagnostics and prevention of backup startup on an unmounted target. Release note required. Actual Unraid unplug/reconnect verification remains a maintainer test; automated checks should simulate faults rather than disconnect real hardware.

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

Implemented in PR #494 with dedicated commit 2facb94.

  • Verify that the configured USB target is a mounted directory with write access. Existing unmounted directories no longer pass; missing/unmounted/read-only targets keep the existing skipped outcome.
  • Report USB access failures as usb_mount_access_failed with exit code 2 and a clear target/OS-error message in logs, status, lifecycle events and failure notifications. The runner stops before Docker/VM operations and Borg, releases its locks and avoids repository queries during failure finalization.
  • No new settings, write probes, automatic mounts or migration.

Validation: 37 focused tests passed, including simulated EIO/ENODEV and the real runner's error/cleanup path. Final preflight for 2facb943811ba21af3bd725003fcffa4683fc1e8 ran once: 947 passed in 276.02s (0:04:36), none skipped, plus syntax checks. Local app/assets and API checks passed. Published package, source/provenance, permissions and MD5 were independently verified.

Test-channel version 2026.09.10.1633 is available via the existing test-channel manifest. Already migrated installations can update directly.

Actual Unraid hardware verification remains pending. Verify normal mounted operation and the existing skipped outcome after properly unmounting the test drive. If the original access error recurs, the log/status should identify the USB problem and state that the backup was not started. Keep this issue open pending user verification and PR acceptance.

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