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_DIR for the filesystem and the VELA_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

  1. 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, default blobs/) to this store.

  2. Add the R2 settings, but keep serving from the filesystem

    Add the VELA_R2_* variables to /etc/vela/vela.env and leave VELA_STORAGE=fs. Recreate the container so it picks up the new environment (Docker reads --env-file only at creation).

  3. Take a backup

    docker exec vela velad backup /data/backups/pre-r2 --verify
  4. Dry run

    docker exec vela velad storage migrate --from fs --to r2 --dry-run

    Verifies every source blob and reports what would be copied, without writing anything.

  5. 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 r2

    It prints progress and a summary of copied, skipped and failed blobs. Rerun it until nothing fails.

  6. Switch the backend

    Set VELA_STORAGE=r2 and keep VELA_ACCEL_PREFIX empty, 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 proxy

    If you used nginx accel, switch nginx to r2.conf as well.

  7. Verify delivery

    Download a few files of each visibility, check a signed link, and upload a test file. Resume writes.

  8. Clean up the source (optional)

    Once you are confident, delete the local copies:

    docker exec vela velad storage migrate --from fs --to r2 --delete-source

    Deletion 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|r2required

Source backend.

--to fs|r2required

Destination backend; must differ from the source.

--dry-run

Verify sources and report planned copies; no content changes. Cannot be combined with --delete-source.

--delete-source

After 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.