megachangelog
Feature

R2 bucket locks for retention policies

You can now set retention policies on R2 buckets using bucket locks to protect objects from accidental or malicious deletion for a specified duration, until a date, or indefinitely. Each bucket can have up to 1,000 lock rules with prefix-based configurations.

You can now use bucket locks to set retention policies on your R2 buckets (or specific prefixes within your buckets) for a specified period — or indefinitely. This can help ensure compliance by protecting important data from accidental or malicious deletion.

Locks give you a few ways to ensure your objects are retained (not deleted or overwritten). You can:

  • Lock objects for a specific duration, for example 90 days.
  • Lock objects until a certain date, for example January 1, 2030.
  • Lock objects indefinitely, until the lock is explicitly removed.

Buckets can have up to 1,000 bucket lock rules. Each rule specifies which objects it covers (via prefix) and how long those objects must remain retained.

Here are a couple of examples showing how you can configure bucket lock rules using Wrangler:

Ensure all objects in a bucket are retained for at least 180 days

npx wrangler r2 bucket lock add <bucket> --name 180-days-all --retention-days 180

Prevent deletion or overwriting of all logs indefinitely (via prefix)

npx wrangler r2 bucket lock add <bucket> --name indefinite-logs --prefix logs/ --retention-indefinite

For more information on bucket locks and how to set retention policies for objects in your R2 buckets, refer to our documentation.

r2storagecompliancedata-protectionretention

Source: original entry ↗

More from Cloudflare

Follow Cloudflare to get its new changes in your feed and email digest.

Fix2026.8.2115.0

Cloudflare One Client for Linux

A new GA release of Cloudflare One Client for Linux is now available. This hotfix addresses an issue with building trusted certificate chains.

linuxclientcertificateshotfix
See all Cloudflare changes →