# Make your offsite copy ransomware-proof with Object Lock

> Point Stonebridge at an S3 bucket with Object Lock, and even a stolen admin password can't delete your backups.

- URL: https://nginx-example.notra.site/blog/s3-object-lock-guide
- Published: 2026-08-20
- Authors: Ines Hartmann
- Tags: guides

Ransomware groups learned years ago to delete backups before they encrypt anything. If your backup server can delete its offsite copy, so can anyone who takes over the backup server.

Object Lock fixes this at the storage layer. Each object gets a retention date, and until that date nobody can delete or overwrite it, including the bucket owner. Stonebridge 3.4 sets that date on every chunk it uploads.

## Create a bucket with Object Lock

Object Lock has to be turned on when the bucket is created. You can’t add it later.

**AWS S3**

```bash
aws s3api create-bucket --bucket acme-backups \
  --object-lock-enabled-for-bucket
```

**MinIO**

```bash
mc mb --with-lock local/acme-backups
```

**Backblaze B2**

```bash
b2 bucket create --file-lock-enabled acme-backups allPrivate
```

## Point Stonebridge at it

```bash
sb target add offsite \
  --s3 https://s3.eu-central-1.amazonaws.com/acme-backups \
  --object-lock compliance --retention 30d
```

Use `compliance` mode. In `governance` mode, a user with the right permission can still remove the lock, which is exactly the permission an attacker goes looking for.

> **Retention costs money**
>
> Locked objects can’t be pruned until their retention ends. With 30 days of retention, plan for about 30 days of changed data on top of your normal storage.

## Test it

Try to delete a chunk with the same credentials Stonebridge uses. It should fail with `AccessDenied`. If it succeeds, the bucket was created without Object Lock, and you need a new one.
