Migrate Docker volume uploads to S3 without breaking existing links
Copy existing uploads into a private S3 bucket, verify file checksums, and keep your application download links stable.
On this page
Copy the files from your Docker volume into a private S3-compatible bucket, then keep your app's existing /uploads/… route and have it read from the bucket. The storage address can change without changing the URL your customers already have. Keep the same hostname, URL paths and access rules when you cut over.
For example, /uploads/invoices/receipt.txt stays the app URL. The app now reads the object key uploads/invoices/receipt.txt from a private Gregale bucket rather than opening a file inside the container.
Don't use this for databases. Use a database-aware backup and restore for Postgres, SQLite or other live database files. An object bucket is not a mounted filesystem.
Try it with sample files before moving yours
Download the Express starter and unpack it. Use Node.js 24, the Gregale CLI, a disposable workspace with object storage available, and a unique name for your test app and bucket. The two files in fixtures/uploads stand in for a read-only snapshot of your old volume.
APP=your-unique-uploads-demo
gregale deploy --name "$APP" --create-only --require-authn
gregale add bucket "$APP" --app "$APP" --permission read_write --prefix DEMO_S3
gregale bucket list "$APP"
Do not pass --public. Copy the bucket ID from the list and set BUCKET_ID locally. The binding injects a sealed bucket credential so the app doesn't need your Gregale API token. Set a separate app-only demo token:
export DEMO_TOKEN="$(openssl rand -hex 32)"
printf 'DEMO_TOKEN=%s\n' "$DEMO_TOKEN" | gregale env set --app "$APP" --from-stdin
node copy-volume.mjs "$APP" "$BUCKET_ID"
gregale deploy --name "$APP" --require-authn --rollout immediate --wait
The script writes each object only if the key doesn't exist, downloads it again and checks its SHA-256. It prints one receipt per file with the key, original URL path and checksum. A partial run leaves any copied objects in place; the script refuses collisions on retry rather than silently overwriting. For this demo, use a fresh disposable bucket if you need to start over.
Prove the old links and new uploads survive a redeploy
Use the HTTPS platform URL printed by deploy. Keep DEMO_TOKEN exported and give the smoke script the owning workspace's Gregale request credential as FAAS_TOKEN. Keep both tokens out of the starter and out of commits.
node smoke.mjs "https://YOUR-APP.gregale.app" v1
The script reads both migrated files at the original relative URLs, including a name with a space. It checks the exact bytes, rejects an unauthenticated read, writes a new file and saves its URL in a local marker.json. Next, change the literal fallback from 'v1' to 'v2' in the last makeApp call in app.mjs. Deploy to the same app without replacing its bucket. Immediate routing here is only for the disposable sample:
gregale deploy --name "$APP" --require-authn --rollout immediate --wait
node smoke.mjs "https://YOUR-APP.gregale.app" v2
The v1 script reserves the marker before sending the upload, so rerunning it with the same marker does not send a second POST. If the upload attempt fails and leaves an incomplete marker, use a fresh disposable setup rather than assuming the write did not happen.
The second run checks that the app reports the new version and that both old files and the new upload still return the exact bytes. It reads an app-owned response instead of relying on platform health alone. The sample uses a shared token and serves downloads as attachments; in a real app keep its user/session and per-file authorization checks, its expected download headers, and its existing user-facing URL behavior.
Verified on Gregale: Both migrated files matched their SHA-256 checksums. A repeat copy was refused rather than overwriting an object. The running app returned both original URL paths and wrote a new file. After a second deployment took all traffic on the same app and bucket, all three files still returned the exact bytes. An unsigned bucket read and unauthenticated app reads were denied.
Cut over a real app
- Inventory the source. Record the hostname, route, relative paths, object metadata your clients rely on, and how uploads and deletes work. Export a read-only snapshot. On Railway, volume file access can download an archive you already created; downloading individual files is not a consistent snapshot. Coolify can archive eligible mounts. On a self-managed host, see Docker's volume backup guide. Back it up independently.
- Test the path mapping. Stage a representative copy in a private bucket. Check nested paths, percent encoding, filename collisions, permissions, thumbnails or range requests if clients rely on them, and direct signed links that point at the old storage host. This starter intentionally handles only straightforward ASCII filenames and small files. For large files use multipart uploads.
- Stop writes for the final copy. Pause legacy uploads and deletes, produce a final inventory and compare checksums. Since the sample copier refuses overwrites, copy the frozen snapshot into an empty destination or use an explicit reconciliation that adds new keys, replaces changed keys, and removes stale keys. An initial copy alone misses later changes and deletes. Confirm the new app serves the same authorized URLs and writes only to the bucket.
- Switch traffic last. Keep the original hostname and path for existing links. Leave the old volume intact and read-only until the cutover is confirmed. If you need to go back after accepting new uploads, reconcile the new writes and deletes before restoring the old app as the writer.
This example does not migrate a live Railway or Coolify project or change DNS. When you're done with the sample, remove its objects, private bucket and disposable app. For the broader move, see Migrate from Railway or Migrate from Coolify.
Spotted a problem on this page? Tell us