You have an S3 bucket carrying a few hundred gigabytes to a few dozen terabytes of static assets — product images, video segments, downloadable installers, build artifacts — and your monthly CloudFront or third-party CDN bill is dominated by transfer charges. R2 is S3-compatible enough that most existing tooling works after a single endpoint-URL change, and it doesn’t charge for egress. The migration is mechanical; the discipline is in the sequence: copy first, verify integrity, then cut DNS over atomically. Do it in the wrong order and you serve broken images for a week.
How to verify
Before you start, get an accurate picture of what’s in S3 and how it’s reached today.
# Total bytes and object count in the source bucket
aws s3api list-objects-v2 \
--bucket prod-media \
--query "[length(Contents), sum(Contents[].Size)]" \
--output text
# Sample object metadata — including content type, ETag, cache headers
aws s3api head-object --bucket prod-media --key images/hero-1.jpg
# What's hitting the bucket today? Read S3 access logs or CloudFront logs.
# Useful to know peak request rate before flipping DNS.
# R2 destination — point AWS CLI at the R2 endpoint
aws configure --profile r2
# Then put your R2 access key ID + secret access key, region "auto"
aws s3 ls \
--endpoint-url https://<account-id>.r2.cloudflarestorage.com \
--profile r2
The --endpoint-url flag is the entire change for AWS CLI; once it points at <account-id>.r2.cloudflarestorage.com, aws s3 cp, aws s3 sync, and aws s3api all work against R2 as if it were S3. Same with rclone, s3cmd, and most SDKs.
What’s happening
R2’s API surface implements the S3 dialect that ~95% of tools actually use. The GET, PUT, HEAD, DELETE, LIST, multipart upload, and presigned URL operations all work. A few S3 features that R2 does not currently implement: server-side encryption with KMS-managed keys (R2 always encrypts at rest, but with Cloudflare-managed keys), object tagging, S3 Object Lock, S3 Select, S3 Glacier storage classes, and S3 Transfer Acceleration. If your migration depends on one of those, validate the workaround before you start copying.
The economics are simple enough to model on the back of an envelope: take your monthly bytes-out from S3 to internet and from S3 to CloudFront, multiply by the relevant rates, and that’s the bill that disappears. What stays on R2 is the per-byte stored cost (lower than S3 standard), class-A operations for writes/lists, and class-B operations for reads. For a bucket with high read traffic and low write churn, the bill is dominated by class-B reads, which is still typically a fraction of the egress you eliminated.
ETags are how you’ll verify integrity end-to-end. R2 computes an MD5 ETag for single-part uploads (matching S3 behavior). For multipart uploads, R2 returns an ETag in the S3 multipart format (MD5-of-MD5s-N) — it won’t equal the MD5 of the whole object, but it equals the S3 multipart ETag for an upload performed with the same part size. That means rclone check and aws s3 sync will both treat the objects as identical when the part size matches. If you upload with a different part size, you’ll see ETag mismatches even when the content is byte-identical.
The procedure
1. Create the destination bucket and an API token. Token is scoped to one bucket, with Object Read & Write permission. Generate it in the dashboard under R2 > Manage R2 API Tokens, then save the access key ID and secret in a ~/.aws/credentials profile named r2.
npx wrangler r2 bucket create media-r2
Add to ~/.aws/credentials:
[r2]
aws_access_key_id = <r2-access-key>
aws_secret_access_key = <r2-secret>
region = auto
2. Test with a small slice first. Don’t sync 4 TB on the first attempt. Pick a representative prefix (images/2026-01/) of a few GB and copy it over. Verify ETags match, verify a Worker or custom domain serves the objects correctly, verify cache headers survived the transfer.
aws s3 sync \
s3://prod-media/images/2026-01/ \
s3://media-r2/images/2026-01/ \
--endpoint-url https://<account-id>.r2.cloudflarestorage.com \
--profile r2 \
--copy-props metadata-directive
The --copy-props metadata-directive flag preserves Content-Type, Cache-Control, and user-defined metadata from the source. Skip it and you’ll end up with application/octet-stream on every object.
3. Use rclone for large transfers. For multi-TB jobs, rclone is faster and more resilient than aws s3 sync because it parallelizes aggressively and resumes cleanly after interruption.
Create ~/.config/rclone/rclone.conf:
[s3-source]
type = s3
provider = AWS
access_key_id = <aws-key>
secret_access_key = <aws-secret>
region = us-east-1
[r2-dest]
type = s3
provider = Cloudflare
access_key_id = <r2-key>
secret_access_key = <r2-secret>
endpoint = https://<account-id>.r2.cloudflarestorage.com
region = auto
Then run the migration:
rclone sync s3-source:prod-media r2-dest:media-r2 \
--transfers 64 \
--checkers 32 \
--s3-chunk-size 64M \
--s3-upload-concurrency 4 \
--progress
Tune --transfers and --s3-chunk-size to your bandwidth and object size distribution. The 64M chunk size is a sane default for objects between 100 MB and 10 GB; bump to 256M for video archives, drop to 16M for swarms of small files.
4. Verify integrity at scale. rclone check walks both buckets and compares object presence, size, and ETag.
rclone check s3-source:prod-media r2-dest:media-r2 \
--size-only --one-way \
--log-file=migration-check.log \
--log-level INFO
Use --size-only for an initial sweep (much faster) and a full ETag check on a sampled subset. Any object that fails the ETag check should be re-uploaded with the matching part size before cutover. Sample 1% of objects across the size distribution for spot integrity checks via sha256sum if the data is sensitive.
5. Set up the production access path on R2. This is the moment to decide how callers will reach R2 — public custom domain or Worker (see R2 buckets access patterns). Attach the domain, attach the binding, set Cache-Control policy on any objects that need overrides, and confirm a HEAD request returns the same headers it did from S3.
6. Incremental sync, then atomic cutover. Once the bulk transfer is in place, run incremental syncs every 5-15 minutes to catch new and updated objects until cutover.
# Run on cron during the cutover window
rclone sync s3-source:prod-media r2-dest:media-r2 \
--transfers 32 --checkers 16 --max-age 30m
When the bucket has been quiet for one sync cycle, flip DNS. For a custom domain on Cloudflare, that’s a single change to your cdn hostname — update the CNAME from <cdn-distribution>.cloudfront.net to the R2 custom-domain target. TTL is what determines how fast the world sees the swap; if you’ve kept the record at TTL 300, the cutover completes in five minutes.
7. Watch for one cycle, then decommission. Leave the S3 bucket up for at least a week with read access in case a long-lived client cached an S3-direct URL or you find an object that didn’t transfer. Look at CloudWatch S3 request counts — if they trend to zero for seven days, you’re safe to disable public access. Don’t actually delete the source bucket for another 30 days; the cost of keeping it is tiny compared to the cost of finding out you needed it.
Common pitfalls
- Forgetting
--copy-props metadata-directive(or rclone’s--metadata), then discovering every object on R2 serves asapplication/octet-stream. - Mismatched multipart part sizes —
rclonedefaults differ from the AWS CLI defaults, which produces “different” ETags for byte-identical objects. - Skipping the small-slice pilot and going straight to a 10 TB sync, only to find out four hours in that an object name contains characters R2 doesn’t accept the same way.
- Flipping DNS before the final incremental sync, missing the last few minutes of writes, then serving 404 for newly uploaded objects.
- Deleting the S3 bucket too soon — leave it read-only for at least 30 days while you watch for stragglers.
In the engagements we run, S3-to-R2 is typically one of the first wins when we take over an estate that’s been paying CDN egress for years. The mechanics are an afternoon; the discipline of the pilot, the integrity check, and the watch period is what keeps the cutover from breaking a content pipeline. Managed Operations is the layer we run for clients who want this sequenced cleanly.