Skip to content

Add optional Wake-on-LAN and remote shutdown support for backup repositories #89

Description

@borg-codex-bot

Goal

Add optional Wake-on-LAN and remote shutdown support for backup repositories. This should allow a backup job to wake a remote repository host, wait until the repository is reachable, run the backup, and optionally shut the host down again after a successful run.

Background

Some users keep backup targets on a separate NAS, Unraid server, or other remote host that is normally powered off. Today Borg Backup UI can fail clearly when the repository is unreachable, but it cannot help with powering the target on before a scheduled backup.

Borg Backup UI should support this as an explicit job-level feature. It must not silently treat every unreachable repository as a Wake-on-LAN target.

Proposed UX

Add a job-level section, for example Remote host control, in the wizard/edit flow.

Suggested fields:

  • Enable remote host control
  • Host identifier, for example backup-nas-01
  • Wake-on-LAN enabled
  • MAC address
  • Optional broadcast address or network interface
  • Wait time after sending WOL
  • Maximum wait time until host/repository is reachable
  • Reachability check mode:
    • Ping host
    • TCP port check, for example SSH port 22
    • Repository path reachable
    • Borg repository readable
  • Optional shutdown after successful backup
  • Optional shutdown command via SSH
  • SSH host
  • SSH user
  • SSH key path
  • Optional shutdown on failed backup, default off

The UI should make clear that shutdown is only attempted when this job woke the host itself.

Recommended implementation phases

Phase 1: Wake before backup

  • Add job metadata for remote host control.
  • Send Wake-on-LAN magic packet before the backup when enabled.
  • Wait and retry reachability checks before starting Borg.
  • Fail the job with a clear error if the host or repository does not become reachable.
  • Log all steps without exposing secrets.
  • No automatic shutdown in this phase.

Phase 2: Optional shutdown after successful backup

  • Add SSH-based shutdown after a successful backup.
  • Only shut down the host if the current job woke it.
  • Default behavior: do not shut down after failed backups.
  • Log shutdown success/failure clearly.
  • Surface shutdown warnings in UI/history.

Phase 3: Shared remote host coordination

  • Support a shared host identifier for multiple jobs.
  • Add locking/reference tracking so one job cannot shut down a host while another job using the same host is running.
  • Consider pending scheduled jobs before shutdown if practical.

Technical analysis

Wake-on-LAN can be implemented without external dependencies by sending a UDP magic packet from Python. Configuration should stay in the job metadata.

Shutdown should be more conservative. SSH is the most portable approach already aligned with repository workflows. Passwords should not be used directly; key-based SSH is preferred. Any secret material must use the existing secret handling model.

Reachability checks should be layered and explicit. A ping-only check is not enough to prove a Borg repository is usable. For remote filesystem targets, path checks may be enough. For SSH/Borg repositories, a Borg-level check gives the best signal but is slower.

The backup runtime must track whether it actually sent WOL for this job. Shutdown must depend on that runtime state, not only on static configuration.

Risks and safeguards

  • Do not power off a host that was already running before the job started.
  • Do not power off a shared host while another job is using it.
  • Do not retry forever; use explicit timeouts.
  • Do not hide WOL/shutdown failures.
  • Do not log SSH secrets, tokens, passwords, or private key material.
  • Keep the feature opt-in per job.

Acceptance criteria

  • A job can be configured to send Wake-on-LAN before backup.
  • The job waits until the selected reachability check succeeds or times out.
  • If the target remains unreachable, the backup fails with a clear message.
  • WOL steps are visible in logs.
  • Optional SSH shutdown can be configured after successful backup.
  • Shutdown is only attempted if the job woke the host itself.
  • Secrets are not written to normal config files and are never logged.
  • Multiple jobs using the same remote host can be protected from unsafe shutdown behavior, at least by a documented lock/host-id mechanism.

Open questions

  • Should Phase 1 only support local path repositories, or also SSH repositories immediately?
  • Which reachability check should be the default?
  • Should shutdown be hidden until Wake-on-LAN is configured?
  • Should this feature live in the wizard only, or also on the Storage page for profile-level defaults?

Metadata

Metadata

Assignees

No one assigned

    Labels

    area::uiUser interface, visual design, and frontend interaction patternsimpact::user-visibleVisible effect for plugin usersphase::post-publicationPlanned after the initial public releaserelease-note::yesInclude in user-facing release notestype::featureNew user-facing or plugin feature

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions