Storage Migration
velad storage migrate copies every referenced blob from one backend to the other while keeping blob IDs and the database unchanged. Because both backends address content by the same IDs, switching is then a one-line configuration change.
How it works
- Reads the configuration of both backends, regardless of the current
VELA_STORAGE:VELA_DATA_DIRfor the filesystem and theVELA_R2_*variables for the bucket. - Copies every blob referenced by live objects and the trash.
- Checks destinations first — size and SHA-256 — so blobs already copied and verified are skipped. Each new copy is read back and verified.
- Never changes the database.
- Takes the backup lease: blobs are pinned (the collector deletes nothing) and other migrations and backups are excluded. It does not block uploads or metadata changes — that is your job.
- Preflights sizes: migrating to R2 fails before copying anything if a stored object exceeds
VELA_R2_PART_SIZE × 10000. - Is resumable: rerun it after an interruption and it continues where it stopped, even if some source copies were already deleted.
Filesystem → R2
-
Prepare the bucket
Create a private bucket, a lifecycle rule and a bucket-scoped token as described in Cloudflare R2 & S3. Dedicate the prefix (
VELA_R2_PREFIX, defaultblobs/) to this store. -
Add the R2 settings, but keep serving from the filesystem
Add the
VELA_R2_*variables to/etc/vela/vela.envand leaveVELA_STORAGE=fs. Recreate the container so it picks up the new environment (Docker reads--env-fileonly at creation). -
Take a backup
docker exec vela velad backup /data/backups/pre-r2 --verify -
Dry run
docker exec vela velad storage migrate --from fs --to r2 --dry-runVerifies every source blob and reports what would be copied, without writing anything.
-
Quiesce writes and copy
Stop uploads, moves and deletions for the duration — pause your CI jobs and tell users. Then run the migration:
docker exec vela velad storage migrate --from fs --to r2It prints progress and a summary of copied, skipped and failed blobs. Rerun it until nothing fails.
-
Switch the backend
Set
VELA_STORAGE=r2and keepVELA_ACCEL_PREFIXempty, then recreate the container — a plain restart does not reload the env file:sudoedit /etc/vela/vela.env # VELA_STORAGE=r2 docker stop vela && docker rm vela VELA_IMAGE=xchunk/vela:0.9.0 ./examples/docker/run-r2.sh docker logs vela | grep 'velad started' # delivery=r2 proxyIf you used nginx accel, switch nginx to
r2.confas well. -
Verify delivery
Download a few files of each visibility, check a signed link, and upload a test file. Resume writes.
-
Clean up the source (optional)
Once you are confident, delete the local copies:
docker exec vela velad storage migrate --from fs --to r2 --delete-sourceDeletion starts only after every destination has been verified, and a failed deletion can be resumed by running the command again.
Never delete from a serving backendDo not run --delete-source while the source backend is still the one velad serves from. Keep source copies until delivery from the new backend has been verified.
R2 → filesystem
The reverse direction follows the same steps with --from r2 --to fs and run-fs.sh (or run-fs-accel.sh). Make sure the data directory has enough free space for every live and trashed object — the filesystem stores them all locally.
docker exec vela velad storage migrate --from r2 --to fs --dry-run
docker exec vela velad storage migrate --from r2 --to fs
# switch VELA_STORAGE=fs, recreate the container, verify
docker exec vela velad storage migrate --from r2 --to fs --delete-source
Flags
--from fs|r2requiredSource backend.
--to fs|r2requiredDestination backend; must differ from the source.
--dry-runVerify sources and report planned copies; no content changes. Cannot be combined with --delete-source.
--delete-sourceAfter every destination is verified, delete the source blobs. Stop writes first.
Things to know
- Writes during migration: blobs uploaded after the migration started are not copied. Quiesce writes from the first copy until the switch, or run the migration again just before switching.
- Dedicated prefix: never share a bucket prefix between two Vela stores — orphan cleanup would treat the other store's blobs as unreferenced.
- Backups afterwards: in R2 mode, backups become metadata-only. Set up paired bucket backups before relying on the new setup.
- Other S3 providers: the procedure is identical; configure the endpoint and region as described in other S3-compatible services.