Skip to content

feat(ns-plug): dual-send backup to my-new proxy#1608

Merged
gsanchietti merged 1 commit into
mainfrom
feat/backup-dual-send-proxy
May 19, 2026
Merged

feat(ns-plug): dual-send backup to my-new proxy#1608
gsanchietti merged 1 commit into
mainfrom
feat/backup-dual-send-proxy

Conversation

@edospadoni
Copy link
Copy Markdown
Member

@edospadoni edospadoni commented Apr 22, 2026

Summary

During the migration window, mirror every configuration-backup upload to the new my.nethesis.it platform via the translation proxy, in addition to the existing upload to the legacy backupd.nethesis.it. The mirror lives in remote-backup's upload action so it covers every backup path (the nightly send-backup cron and manual backups triggered from the UI), and so the eventual cutover is a single localized change to the same file.

Context

The new my.nethesis.it platform ships a first-class configuration-backup subsystem (ingest on collect, managed reads on backend, S3-compatible storage) — see the referenced issues. During the migration window NethSecurity keeps uploading to the legacy backupd and dual-sends to my-new via a translation proxy (nethinfra role). The proxy accepts the existing system_id:secret Basic Auth pair and translates it into the my-new system_key:system_secret as it forwards the request to collect, so nothing changes on the appliance in terms of UCI config or registration.

What changes

packages/ns-plug/files/remote-backup, upload action only:

  • After the primary curl ... --upload-file to the legacy backupd completes, its exit code is captured (rc=$?).
  • If ns-plug.config.type == enterprise, the same encrypted blob is POSTed to https://my.nethesis.it/proxy/backup with --data-binary "@$file", reusing the existing $curl_args (--silent --location-trusted --user $SYSTEM_ID:$SYSTEM_SECRET — the proxy translates that legacy pair). Content-Type: application/octet-stream and X-Filename are set so the blob and its user-facing name land as proper S3 object + metadata on my-new.
  • The mirror is best-effort (|| :): a proxy outage must not fail the primary upload that already succeeded against backupd.
  • The script then exit $rc — the primary backupd upload's exit status is what propagates to the caller, so send-backup's set -e still aborts on a real legacy-upload failure and the md5 dedup marker is not advanced on a failed run (the backup is retried next night). The best-effort mirror never masks a primary failure.

packages/ns-plug/files/send-backup is unchanged (identical to main). Putting the dual-send in the transport layer (remote-backup) instead of the cron wrapper is what the review asked for, and it also means a backup triggered manually from the UI is mirrored too, not just the cron one.

Verified end-to-end on a real NethSecurity appliance: script runs under busybox/ash, $curl_args reuse works, a failing primary still fires the best-effort mirror, rc/exit $rc propagates the primary status, and the mirrored blob lands intact on my-new (matching SHA-256, X-Filename → object metadata, application/octet-stream content type).

Not included

  • Rewriting the legacy upload path — out of scope; happens in a later cycle once the new platform is promoted (the cutover then replaces this best-effort mirror block with the direct collect call, a single-file change to remote-backup).
  • MY registration on the appliance — not needed: the proxy absorbs the credential difference.

Refs: NethServer/my#82 NethServer/my#83

Copy link
Copy Markdown
Member

@gsanchietti gsanchietti left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The change should be done inside the remote-backup script, under the upload action

@edospadoni edospadoni force-pushed the feat/backup-dual-send-proxy branch 2 times, most recently from cef0034 to 5ae3c78 Compare May 19, 2026 06:46
@edospadoni edospadoni requested a review from gsanchietti May 19, 2026 07:08
Adds a second upload to https://my.nethesis.it/proxy/backup after
remote-backup finishes its upload to backupd.nethesis.it. Same
transitional pattern already used by send-heartbeat and send-inventory:
the proxy accepts the existing system_id:secret Basic Auth pair and
translates it into the my-new system_key:system_secret on its way to
the new collect endpoint, so no UCI or registration change is needed
on the appliance.

Gated to enterprise subscriptions via `TYPE = enterprise` to stay in
sync with the other dual-send scripts. Best-effort (`|| :`): a proxy
outage does not block the primary upload that already completed
against backupd, and the md5 marker is still updated so the same
backup is not re-uploaded the next night.

X-Filename is propagated so the user-facing filename ends up as S3
object metadata on my-new.

Refs: NethServer/my#82 NethServer/my#83
@edospadoni edospadoni force-pushed the feat/backup-dual-send-proxy branch from 2852dd5 to 3a1c3e9 Compare May 19, 2026 07:26
Copilot stopped work on behalf of gsanchietti due to an error May 19, 2026 08:20
Copilot AI requested a review from gsanchietti May 19, 2026 08:20
@gsanchietti gsanchietti merged commit e30c549 into main May 19, 2026
1 of 3 checks passed
@gsanchietti gsanchietti deleted the feat/backup-dual-send-proxy branch May 19, 2026 08:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants