Skip to content

feat(docs): add migration script for switching between RustFS and AWS S3 - #809

Merged
pikann merged 2 commits into
masterfrom
feature/add-migration-script-for-switching-storage
Nov 21, 2026
Merged

pikann merged 2 commits into
masterfrom
feature/add-migration-script-for-switching-storage

Conversation

@pikann

@pikann pikann commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Adds scripts/migrate-storage.sh, which moves Paca's object storage between the bundled RustFS and AWS S3 (or any S3-compatible service), in either direction. Documented in docs/deployment/README.md under "Switching between RustFS and AWS S3".

# RustFS -> S3
DEST_STORAGE_BUCKET=my-bucket DEST_STORAGE_REGION=eu-west-1 \
DEST_STORAGE_ACCESS_KEY_ID=AKIA... DEST_STORAGE_SECRET_ACCESS_KEY=... \
bash scripts/migrate-storage.sh --to s3

# S3 -> RustFS (credentials generated unless DEST_STORAGE_* are set)
bash scripts/migrate-storage.sh --to rustfs

How it works

  • Reads the current STORAGE_* values from .env as the source; refuses if the provider already matches --to.
  • Copies the whole bucket (attachments, avatars, plugin bundles when PLUGINS_STORE=s3) with mc in a throwaway container on the compose network, since the RustFS port isn't published.
  • Stops api during the copy by default so nothing is uploaded mid-migration (PACA_STOP_API=no to skip).
  • Verifies the destination holds at least the source's object count and total size.
  • Backs up .env, rewrites STORAGE_*, restarts api. On any failure .env is restored and api restarted with the old config.
  • The source bucket is never modified or deleted.
  • --dry-run previews the copy; PACA_YES=1 runs unattended.

Not covered

  • Only api is restarted; the script prints the follow-up (--scale rustfs=0 after moving to S3) rather than doing it.
  • Helm installs are not handled.

Testing

Both directions run end to end against throwaway containers (a second RustFS container standing in for S3), including a key with spaces, verification, .env rewrite, api restart and the .env rollback on failure. Not yet tried against real AWS S3.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Caution

The --to s3 path reports success but leaves the API talking to the RustFS endpoint: the empty STORAGE_ENDPOINT / STORAGE_PUBLIC_URL values this script writes are replaced by the compose defaults, so uploads fail and downloads 404 after the migration.

Approach: sound — it reuses the mc-in-a-throwaway-container pattern the existing MinIO migration docs already use, copies without touching the source, and keeps a restorable .env backup; the problems are in how the switched config reaches the API, not in the copy/verify design.

Reviewed changes

  • scripts/migrate-storage.sh — new 425-line migration script that mirrors the bucket with mc, verifies object count and size, rewrites STORAGE_* in .env, restarts api, and rolls back on failure.
  • docs/deployment/README.md — new "Switching between RustFS and AWS S3" section documenting both directions, --dry-run, and the --scale rustfs=0 follow-up.

ℹ️ The new script has no automated check

.github/workflows/scripts-pr-ci.yml runs shellcheck and end-to-end smoke tests for the other install/upgrade scripts, but neither its paths: filter nor its shellcheck file list includes scripts/migrate-storage.sh, so a script that rewrites .env and moves production objects gets no CI signal at all. Running shellcheck locally also exits 1 today, so enrolling it needs a couple of annotations first.

Technical details
# scripts CI doesn't cover migrate-storage.sh

## Affected sites
- `.github/workflows/scripts-pr-ci.yml:5-17` — `paths:` filter lists install/upgrade/skills scripts, not `migrate-storage.sh`
- `.github/workflows/scripts-pr-ci.yml:56` — `shellcheck ... scripts/install.sh scripts/upgrade.sh scripts/install-paca-skills.sh`
- `scripts/migrate-storage.sh:310,313,320,343,352` — five `SC2016` (info) warnings for the intentional container-side `$VAR` expansions; shellcheck exits 1 on them

## Required outcome
- At least lint coverage for the new script, with the intentional single-quoted expansions explicitly disabled.

## Suggested approach
- Add `scripts/migrate-storage.sh` to the workflow's `paths:` and to the shellcheck invocation, plus `# shellcheck disable=SC2016` above the `mc_run` call sites (or on the helper) so the existing job stays green. A small smoke test in the style of the existing upgrade.sh storage tests would be valuable given it rewrites `.env`.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using deepseek-v4.1-flash-1017 (free via Pullfrog for OSS) | 𝕏

Comment thread scripts/migrate-storage.sh Resolved
Comment thread docs/deployment/README.md Resolved
Comment thread scripts/migrate-storage.sh Resolved
Comment thread scripts/migrate-storage.sh Resolved

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

✅ No new issues found.

Approach: sound — the --to s3 fix writes explicit endpoint/public-URL values instead of relying on empty strings surviving Compose interpolation, so it sidesteps the ${VAR:-default} substitution trap without touching the compose file.

Reviewed changes

  • Enrolled the script in CI — added to the scripts-pr-ci paths: filter and shellcheck list, with a file-wide SC2016 disable for the intentional container-side expansions; the lint job passes.
  • Docs now fetch the script — the section curls migrate-storage.sh into the install directory instead of assuming a scripts/ folder that a standard install never creates.
  • --to s3 writes real storage values — STORAGE_ENDPOINT and STORAGE_PUBLIC_URL are set to the regional endpoint, so Compose no longer substitutes the RustFS defaults and the presigned-URL rewrite is a no-op.
  • Second mirror pass — when the API is left running, a second mc mirror runs before the switch, and the warning now states the residual upload window accurately.
  • Secrets leave the docker argv — credentials are exported and passed as -e NAME, so they no longer appear in ps.

Pullfrog  | View workflow run | Using deepseek-v4.1-flash-1017 (free via Pullfrog for OSS) | 𝕏

@pikann
pikann merged commit fa337d7 into master Nov 21, 2026
6 checks passed
@pikann
pikann deleted the feature/add-migration-script-for-switching-storage branch November 21, 2026 05:21
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