Cloudflare R2, Amazon S3 and Backblaze B2 all speak the same S3-compatible API, and WordPress offload plugins treat them as interchangeable, so the choice is not about features. It comes down to how each one bills traffic leaving the bucket, what it takes to serve files from a domain you control, and what a restore looks like once the bucket holds the only copy. R2 charges no egress fees, though read and write operations are billed per request, and it serves nothing publicly in production until you connect a custom domain or a Worker. B2 has the cheapest storage, free egress up to three times the data you store each month, and unlimited free egress to partner CDNs such as Cloudflare. S3 bills egress and has the deepest tooling and widest plugin support. After the comparison comes the migration: sizing the library, scoped credentials, the first full sync, the custom domain, rewriting URLs, a final catch-up sync, and the checks that let you take the origin server out of the path.
What you’ll accomplish
- A backend chosen against your own read volume and CDN situation, not against a feature list.
- Uploads served from a domain you control, so the backend can change later without touching a stored URL.
- A byte-verified copy of the library in the bucket, checked before anything is deleted locally.
- A rollback that is one plugin setting away, because the origin copy is still there.
- A written recovery story: what happens to existing images and to new uploads when the bucket is unreachable.
Prerequisites
WordPress 6.x on PHP 8.x, WP-CLI available, and shell access to the origin. You need an account with the provider you pick and the ability to create a bucket plus scoped API credentials. On the WordPress side, install either WP Offload Media or Media Cloud — both handle URL rewriting and the upload hook. The bulk copy below uses provider-neutral CLI tooling, so it works with either plugin.
The three backends differ in operation, and it is worth being blunt about how before you commit.
Cloudflare R2 charges no egress fees for data served to the internet, which is the whole reason it enters this conversation. Read and write operations are still billed per request. The catch: an R2 bucket is private and has no production-ready public URL until you attach a custom domain on a zone in your Cloudflare account, or front it with a Worker. Its r2.dev address is rate-limited and meant for development only. Region is a location hint, not a hard selection. The Cloudflare R2 documentation covers compatibility and the public-access options.
Backblaze B2 has the lowest storage cost of the three, and Backblaze includes free egress up to three times your average monthly storage, plus unlimited free egress to partner CDNs, Cloudflare among them. Past that allowance, without a partner CDN in front, downloads are billed. Its S3-compatible endpoint is newer than the B2-native API, so confirm your plugin version targets the S3 one.
Amazon S3 bills egress, discounted when served through CloudFront. In exchange you get the reference implementation, lifecycle rules, versioning, object lock, and IAM roles that let an EC2-hosted site avoid storing keys at all. Every offload plugin supports it first and best; the Amazon S3 documentation is the behaviour the other two are measured against.
No dollar figures appear here on purpose: rates change, and the answer depends on your read-to-write ratio and geography. Take the real numbers from step 1 into each vendor’s own pricing calculator.
How it works
An offload plugin does two separate jobs, and confusing them causes most broken migrations.
The first is upload interception. When WordPress finishes writing an attachment and its generated sizes into wp-content/uploads/, the plugin uploads each file to the bucket and records the mapping in post meta. Whether the local files survive is a setting: “copy” leaves them, “remove after upload” deletes them. Only the second mode reclaims disk; only the first gives you a rollback.
The second is URL rewriting at display time. The plugin filters wp_get_attachment_url plus the srcset and image-source filters, so a template asking for an attachment URL gets the bucket-backed host instead of the site host. Nothing in the database changes — which is why the rewrite is reversible by flipping one setting, and why an <img> tag hard-coded into post content by a page builder is untouched by it. WP Offload Media stores its configuration in the as3cf_settings option, which is exactly why credentials belong in wp-config.php: database options land in every backup and staging clone.
Thumbnails matter more than people expect. One uploaded photo becomes a dozen or more files: the original, the registered sizes, and whatever the theme adds. By file count wp-content/uploads is mostly derivatives, and a sync that misses them produces pages where the full-size image loads while every responsive variant 404s. Srcset is generated from _wp_attachment_metadata, so the variants must exist in the bucket under exactly the paths that metadata implies.
Here is how the three compare on the dimensions that shape day-to-day operation:
| Dimension | Amazon S3 | Cloudflare R2 | Backblaze B2 |
|---|---|---|---|
| S3 API surface | The reference implementation | Broad S3 compatibility; some operations and headers behave differently | S3-compatible endpoint alongside the older native B2 API |
| Egress model | Billed, discounted via CloudFront | No egress fees; operations billed per request | Free up to 3x stored data; unlimited to partner CDNs such as Cloudflare |
| Custom domain | Bucket website endpoint or CloudFront | Required for public serving: custom domain or Worker | Friendly URL via a CDN in front |
| CDN in front | CloudFront natively; any CDN works | Cloudflare, effectively built in | Cloudflare, for the Alliance benefit |
| Lifecycle and versioning | Full lifecycle rules, versioning, object lock | Lifecycle rules; a narrower feature set | Lifecycle rules and file versions |
| Multipart and large objects | Well-trodden for very large files | Fine for media; test if you host long video | Fine for media; test if you host long video |
| Restore path | Widest third-party tooling | Any S3-compatible tool; rclone is the safe default | Any S3-compatible tool plus B2’s own CLI |
Read the restore row twice. Once the origin no longer holds the files, “restore the site” means restore the database and pull tens of gigabytes back out of a bucket. Prove that pull works before you need it.
Step-by-step
-
Size the library first. Total bytes drive the storage line; file count drives sync duration and API-call volume.
du -sh wp-content/uploads find wp-content/uploads -type f | wc -l wp post list --post_type=attachment --format=countThree numbers that only mean something together, for example
84G,412903, and31544. A file count ten to fifteen times the attachment count is normal and confirms derivatives dominate. Much higher, and something is generating sizes nobody uses — worth trimming before you copy it all. -
Create the bucket and credentials scoped to it. Create an API token or access key restricted to that one bucket, read and write; do not reuse an account-wide key. Note the S3-compatible endpoint: R2 gives an account-specific
https://<account-id>.r2.cloudflarestorage.com, B2 a regionalhttps://s3.<region>.backblazeb2.com, S3 the standard regional endpoint. Confirm the credentials first:aws s3 ls s3://my-media-bucket/ --endpoint-url https://ENDPOINT --profile offloadAn empty result with exit status
0is success on a new bucket.An error occurred (InvalidAccessKeyId)or(AccessDenied)means the key is wrong or not scoped here — fix it now, not after a half-finished sync. -
Do the first full sync with
rclone. It behaves the same against all three endpoints, checksums rather than trusting sizes, and resumes cleanly. Configure a remote of types3, then copy the tree preserving thewp-content/uploadsprefix:rclone config rclone copy wp-content/uploads offload:my-media-bucket/wp-content/uploads \ --transfers 16 --checkers 32 --fast-list --progress --exclude '*.tmp'rcloneprints a live line ending inTransferred: 84.012 GiB / 84.012 GiB, 100%followed byElapsed time. A non-zeroErrors:count is not something to skip past — rerun the same command; it only moves what is missing. Flags are documented in the rclone global flags reference. The AWS CLI alternative,aws s3 sync wp-content/uploads s3://my-media-bucket/wp-content/uploads --endpoint-url https://ENDPOINT, works too, but recent CLI versions send checksum headers that some S3-compatible endpoints reject. -
Verify the copy before you trust it. This is the step people skip and later regret.
rclone check wp-content/uploads offload:my-media-bucket/wp-content/uploads --one-way rclone size offload:my-media-bucket/wp-content/uploadscheckshould end with0 differences found, andsizeshould print aTotal objectsfigure matching your localfind | wc -lwith aTotal sizewithin a rounding error ofdu -sh. A few dozen missing files means they changed mid-copy, which step 8 handles; thousands means the copy is incomplete. -
Bind a custom domain to the bucket, before you rewrite anything. Serving from
media.example.comrather than a provider hostname is what makes the backend swappable later. On R2 that is the bucket’s Settings tab, “Connect Domain”, using a hostname on a zone in the same Cloudflare account; Cloudflare creates the DNS record and the certificate. On S3, point CloudFront at the bucket and add the alternate domain name. On B2, front the bucket with a CDN. Then check from outside:dig +short media.example.com curl -sI https://media.example.com/wp-content/uploads/2026/09/hero.jpg | head -5You want
HTTP/2 200andcontent-type: image/jpeg. A403means the domain is bound but public access is not — on R2 that gap is the most common reason people conclude “R2 doesn’t work”. -
Put credentials in
wp-config.php, not the database. WP Offload Media reads a defined constant in preference to the stored option, keeping the secret out ofwp_optionsand out of every backup and staging clone:define( 'AS3CF_SETTINGS', serialize( array( 'provider' => 'PROVIDER_SLUG', 'access-key-id' => 'YOUR_KEY_ID', 'secret-access-key' => 'YOUR_SECRET', ) ) );Take
PROVIDER_SLUGfrom the plugin’s own storage-provider documentation for the version you installed; the settings screen names it, and a wrong slug fails loudly at connection time. Then confirm the constant is winning:wp option get as3cf_settings --format=jsonThe output should show the bucket and region but no secret. A secret printed here means the option is still authoritative and the constant is not being read.
-
Enable rewriting and point it at the custom domain. Set the bucket, set the path prefix to match what you synced (
wp-content/uploads), turn on delivery with a custom domain ofmedia.example.com, and leave “Remove files from server” off. Confirm WordPress agrees:wp eval 'echo wp_get_attachment_url( 123 ) . PHP_EOL;' wp eval 'echo wp_get_attachment_image_srcset( 123, "large" ) . PHP_EOL;'Substitute a real ID from
wp post list --post_type=attachment --field=ID --format=ids | head -1. Both must printhttps://media.example.com/.... If the first rewrites and the second does not, the srcset filter is off or another plugin runs after it. -
Run the delta re-sync. A busy site added files while step 3 ran; those attachments exist in the database with local files and no bucket object.
rclone copy wp-content/uploads offload:my-media-bucket/wp-content/uploads \ --transfers 16 --checkers 32 --fast-list --progress rclone check wp-content/uploads offload:my-media-bucket/wp-content/uploads --one-wayThe second run should move a handful of files in seconds, and
checkshould then report0 differences found. Run the plugin’s bulk-offload tool afterwards so its post meta matches reality, or WordPress keeps serving those recent attachments from the origin.
Validate it works
Prove the whole path, not the pieces. Upload a fresh image through the admin, then confirm it landed remotely:
wp post list --post_type=attachment --field=ID --format=ids --posts_per_page=1
wp eval 'echo wp_get_attachment_url( NEW_ID ) . PHP_EOL;'
rclone lsl offload:my-media-bucket/wp-content/uploads/2026/09/ | tail -5
The URL must be on media.example.com, and the file must appear in the listing with a plausible size and a fresh timestamp. Next, take an old attachment and verify every generated size resolves:
wp eval 'echo str_replace( ", ", "\n", wp_get_attachment_image_srcset( 123, "full" ) ) . PHP_EOL;' \
| awk '{print $1}' | xargs -I{} curl -s -o /dev/null -w "%{http_code} %{content_type} {}\n" {}
Every line should read 200 image/jpeg or 200 image/webp. One 403 or 404 there is a partial sync, and it surfaces on real pages as a missing image on high-density screens only. Finally, prove the origin can leave the path: rename one uploads month locally and load a page that uses it.
mv wp-content/uploads/2026/08 /root/uploads-2026-08-holdout
curl -s https://example.com/some-post-with-images/ | grep -c 'media.example.com'
The count should match the number of images on the page, and the page should render identically in a browser. Move the directory back afterwards. Only once this passes on a representative sample should you consider “remove files from server” — and even then, keep an independent backup of the bucket rather than treating the bucket as one.
Troubleshooting
Images break after switching because URLs are hard-coded in post content. The plugin rewrites what passes through wp_get_attachment_url; page builders store the absolute URL in the post body or in serialised builder data instead. Use WP-CLI rather than SQL for the search-replace, because builder payloads are PHP-serialised — a raw UPDATE changes the string but not its recorded byte length, and the array then fails to unserialise:
wp search-replace 'https://example.com/wp-content/uploads' 'https://media.example.com/wp-content/uploads' \
--precise --all-tables-with-prefix --report-changed-only --dry-run
Read the report, then rerun without --dry-run. Add --skip-columns=guid: guid is a feed identifier, not a URL to fetch, and rewriting it churns RSS readers. More on the serialised-data trap in running search-replace after a domain change.
The R2 bucket returns 403, or nothing at all. R2 buckets are private until you attach a custom domain or route a Worker to them. The S3 API endpoint (<account-id>.r2.cloudflarestorage.com) authenticates every request and is not a delivery URL — pointing the plugin’s custom-domain field at it produces a site full of 403s. Bind a real hostname, confirm with the curl -sI from step 5, then enable delivery. R2 bucket access patterns covers the public-access options and what each costs operationally.
Mixed-content warnings appear after the cutover. If the rewrite produced http://media.example.com, or the media hostname resolves over HTTP anywhere in the chain, browsers block the request on an HTTPS page. Check the plugin’s Force HTTPS setting and confirm the certificate on the media hostname is issued and served; diagnosing WordPress mixed content covers finding every source.
Fonts or media loaded cross-origin are blocked by CORS. Anything the browser fetches under CORS rules — web fonts in a stylesheet, crossorigin video, canvas reads — needs an Access-Control-Allow-Origin header from the bucket or the CDN once it moves hostname. Plain <img> tags do not, which is why images look fine while a font silently falls back. Add a CORS rule allowing your site origin for GET and HEAD, then verify with curl -sI -H 'Origin: https://example.com' against a font URL.
Local files were deleted before the remote copy was verified. If “remove from server” was on during the initial offload and the sync was incomplete, some files exist nowhere. Restore only wp-content/uploads from the most recent pre-offload backup into a scratch directory, rclone copy from there into the bucket, then rclone check --one-way against the restored tree. Then run wp media regenerate --only-missing to rebuild derivative sizes lost while their originals survived. This failure mode is what makes step 4 non-optional.
When this is the wrong approach
A library that fits comfortably on disk with room to grow does not need this. Offloading adds a network dependency, a second set of credentials, a second thing to back up, and a plugin that must keep working through every WordPress and PHP upgrade. For a small library, a CDN in front of the origin gets the same edge caching and the same offloaded read traffic with none of the moving parts — and that also covers the case where the real problem is read bandwidth rather than disk.
If your content is largely video, price it separately: long files change the multipart, egress, and caching arithmetic enough that a dedicated video platform for the video and local uploads for everything else is often the better split. And if the move is motivated by unmanageable backups, offloading relocates that problem rather than solving it — the bucket needs its own backup and becomes a second system to restore under pressure.
Running WordPress that earns real money deserves an operator — Stack Harbor runs that stack under Enterprise WordPress; book an infrastructure consult.