You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
title: Set retention polices for your R2 bucket with bucket locks
3
+
description: Set retention polices for your R2 bucket with bucket locks
4
+
products:
5
+
- r2
6
+
date: 2025-03-06T10:00:00Z
7
+
---
8
+
9
+
You can now use [bucket locks](/r2/buckets/bucket-locks/) to set retention policies on your [R2 buckets](/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.
10
+
11
+
Buckets can have up to 1,000 [bucket lock rules](/r2/buckets/). Each rule specifies which objects it covers (via prefix) and how long those objects must remain retained. You can:
12
+
13
+
- Lock objects for a specific duration. For example, 90 days.
14
+
- Retain objects until a certain date. For example, until January 1, 2030.
15
+
- Keep objects locked indefinitely.
16
+
17
+
Here's how you can add a bucket lock rule with [Wrangler](/workers/wrangler/):
18
+
19
+
```sh
20
+
npx wrangler r2 bucket lock add my-bucket
21
+
```
22
+
23
+
For more information on bucket locks and how to set retention policies for objects in your R2 buckets, refer to our [documentation](/r2/buckets/bucket-locks/).
0 commit comments