Skip to content

tools: add rclone-based dist mirror script - #4525

Open
ryanaslett wants to merge 1 commit into
nodejs:mainfrom
ryanaslett:dist-mirror
Open

ryanaslett wants to merge 1 commit into
nodejs:mainfrom
ryanaslett:dist-mirror

Conversation

@ryanaslett

Copy link
Copy Markdown
Contributor

Adds tools/dist-mirror/, a replacement for the rsync endpoint on unencrypted.nodejs.org, so we can retire that server (#3960, #4085).

What it is

A ~90-line bash wrapper around rclone's HTTP backend, pointed at https://nodejs.org/dist/. It needs no Cloudflare credentials and doesn't touch R2 directly. It reads the same public listings and files everyone downloads, and the per-file HEAD checks are answered by Cloudflare's cache. Requirements: bash, rclone, jq.

  • Incremental mode (default): copies release directories that are missing locally or were published in the last 14 days, then the top-level files. Version directories are copied before index.json/index.tab, so version managers never see a release listed before its files exist.
  • --full: runs a complete rclone sync, which also catches changes to older releases and deletions.
  • Symlinks: latest/, the latest-* directories and node-latest.tar.gz are skipped during the transfer, then recreated as real local symlinks computed from index.json. The derived map matches the release worker's latestVersions.json exactly. The roughly 70 static v0.x file aliases are mirrored as ordinary files (a few hundred MB of duplicates).
  • Sends a nodejs-dist-mirror User-Agent, so we can recognise mirror traffic in our logs.

Testing

Run against production nodejs.org, with --max-size 2M so large binaries weren't downloaded:

  • The 38 symlinks it created match latestVersions.json entry for entry, and they survive --full syncs.
  • mtimes match upstream, and re-runs transfer nothing.
  • On an up-to-date mirror, an incremental run takes about 2 s. A --full run takes about 52 s (all directory listings plus HEAD requests).
  • shellcheck: clean with the repo's .shellcheckrc and with --norc.

Once this merges, I'll post usage instructions on #3960 for TUNA and the other mirrors.

🤖 Generated with Claude Code

Add tools/dist-mirror, a small wrapper around rclone's HTTP backend that
mirrors https://nodejs.org/dist/ without credentials, as a replacement
for the rsync endpoint on unencrypted.nodejs.org.

The latest-* directories and node-latest.tar.gz are skipped during the
transfer and recreated as local symlinks derived from index.json,
matching the release worker's latestVersions.json.

Refs: nodejs#3960
Refs: nodejs#4085

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Ryan Aslett <raslett@linuxfoundation.org>
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.

1 participant