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

Add Rclone storage backend with WebDAV support

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

Goal

Add a new generic rclone storage type to Borg Backup UI. The first supported backend should be WebDAV for providers such as Nextcloud, ownCloud and other WebDAV-compatible services.

BorgBackup does not support WebDAV directly. When rclone is available on the Unraid host, Borg Backup UI should mount the remote target locally with rclone mount and let Borg use the mounted path as a local repository target.

Requirements

Storage type

  • Add a new storage type: rclone.
  • Support at least the backend webdav initially.
  • Keep the design generic enough to add later rclone backends such as S3, Backblaze B2, Google Drive, OneDrive or Dropbox.

WebDAV profile

A WebDAV profile should support:

  • profile display name
  • WebDAV URL
  • username
  • password or secret
  • optional remote path
  • optional certificate verification setting
  • optional additional rclone options

Secrets must not be stored in plain text in normal configuration files. They must use the existing secret handling model.

Prerequisite checks

When creating or testing a profile, check:

  • rclone is installed
  • rclone version works
  • FUSE or mount support is available
  • target URL is reachable
  • authentication works
  • remote path is readable and writable

Missing prerequisites must produce clear user-facing error messages.

Mount behavior

Before a backup, mount the target with rclone, for example below:

/tmp/borg-backup-ui/mounts/<storage-id>

or another comparable temporary mount path.

After the backup, unmount cleanly.

The implementation must handle:

  • existing mounts
  • mount conflicts
  • locking
  • cleanup after failures
  • mount operation timeouts
  • useful logs
  • no secrets in logs

Borg integration

After a successful mount, Borg should access the repository as a local path, for example:

borg create /tmp/borg-backup-ui/mounts/<storage-id>/<repository> ...

The existing backup flow should change as little as possible. Rclone/WebDAV should be added as another storage abstraction.

Storage UI test

The Storage page should provide a test action for Rclone/WebDAV profiles. The test should verify:

  • rclone availability
  • connection and login
  • mount success
  • write test
  • unmount success

Results must be understandable in the UI.

UI requirements

Add a selectable storage type, preferably Rclone, with backend selection WebDAV initially.

The UI must clearly explain that this feature requires rclone and mount/FUSE support on the host.

Logging

Log relevant steps:

  • rclone checks
  • temporary rclone config creation
  • mount attempts
  • connection tests
  • Borg access
  • unmount
  • cleanup
  • error details

Passwords, tokens and secrets must never appear in logs.

Acceptance criteria

  • A WebDAV target can be created as a new Rclone storage profile.
  • The connection can be tested from the UI.
  • BorgBackup can use a repository on the mounted WebDAV target.
  • The mount is removed reliably after backup completion.
  • UI and logs show understandable errors.
  • Secrets are handled safely and never logged.
  • The implementation is prepared for additional rclone backends.

Implementation note

Build this as a generic rclone storage type and treat WebDAV as the first backend, not as a hard-coded one-off WebDAV integration.

borg-codex-bot avatar Jun 28 '26 08:06 borg-codex-bot

Safety analysis before implementation

This feature should not move directly into implementation. Borg on top of an rclone mount is not equivalent to using a local filesystem or Borg over SSH, and the main product risk is not connection failure but a backup that appears successful while repository data is incomplete, delayed in a VFS cache, or later fails verification.

Current position

  • Treat this as post-publication research first, not as a normal storage feature.
  • Do not expose Rclone/WebDAV as a supported backup target until repository integrity and restore reliability have been proven under failure conditions.
  • If implemented at all before that proof exists, it should be clearly marked experimental/unsupported and separated from the normal storage targets.

Why this is risky

  • Borg's own FAQ recommends avoiding network filesystems for repository storage where possible and prefers running Borg close to the repository storage, for example via borg serve over SSH: https://borgbackup.readthedocs.io/en/stable/faq.html
  • rclone mount uses a VFS layer whose compatibility depends on cache mode. Rclone documents that VFS caching is needed for normal filesystem compatibility and that writeback/cached uploads can remain pending after application close: https://rclone.org/commands/rclone_mount/
  • Rclone also warns that overlapping VFS caches can potentially cause data corruption. Borg repository access therefore needs strict one-writer locking, isolated cache directories, and reliable cleanup.

Required analysis spike before feature work

Create a separate spike/test issue before implementing the storage type. The spike should answer:

  • Which rclone mount flags are mandatory for Borg repositories on WebDAV?
  • Is --vfs-cache-mode writes sufficient, or is --vfs-cache-mode full required?
  • Where can the cache live safely on Unraid, and how much free space is required?
  • How do we detect that all rclone writes have actually reached the remote before unmounting?
  • What happens after UI restart, service restart, host reboot, and rclone process death?
  • Can Borg's repository lock behavior be trusted through the mount for WebDAV providers?
  • Which failure states leave a repository needing borg check or manual repair?

Minimum test matrix before support

A WebDAV/rclone backend should only be considered supportable if these tests pass repeatedly on a controlled WebDAV server and at least one real-world Nextcloud/ownCloud-style target:

  • borg init, multiple borg create, borg list, borg extract, borg prune, borg compact, borg check, and borg check --verify-data.
  • Restore verification with checksum comparison of restored payloads, not just exit-code checks.
  • Backup interrupted by network loss.
  • Backup interrupted by killing the rclone mount process.
  • Backup interrupted by stopping/restarting Borg Backup UI.
  • Host reboot or simulated crash while rclone has pending VFS writes.
  • VFS cache directory full.
  • Remote quota full.
  • Remote path temporarily read-only or permission denied.
  • Two jobs targeting the same rclone profile/repository at the same time.
  • Existing stale mount, stale lock, and cleanup-after-failure scenarios.
  • Repository maintenance actions after an interrupted backup.
  • Restore and restore-test workflows using the mounted repository.
  • Support bundle, UI logs, API errors, and rclone logs verified for secret masking.

Implementation gates if the spike succeeds

Only after the spike should this issue proceed to implementation, with these constraints:

  • Rclone/WebDAV must use the existing storage abstraction, not a parallel backup path.
  • Mounts must be guarded by repository/storage locks.
  • Each profile/repository must use an isolated rclone config and VFS cache directory.
  • Secrets must use the existing secret-file model and never appear in config exports, logs, support bundles, or process listings where avoidable.
  • The UI must clearly explain the rclone and FUSE prerequisites and the experimental/support status.
  • Every backup must verify mount readiness before Borg starts and verify rclone write completion before unmount.
  • Failures must prefer blocking the backup over risking a partially written repository.

Recommendation

Keep #86 open as a post-publication feature idea, but add a dedicated safety spike before any implementation. The first deliverable should be a documented test report and a clear go/no-go recommendation, not production code.

borg-codex-bot avatar Jul 28 '26 10:07 borg-codex-bot