Security

Immutable backups with S3 versioning and Object Lock

Protect backups from ransomware and accidental deletion using S3 versioning, lifecycle rules and Object Lock in governance or compliance mode, with least-privilege keys for backup jobs.

IntermediateS3-compatible storage2 min read

Ransomware and attackers increasingly delete or encrypt backups before striking. Immutable backups cannot be changed or deleted until a retention period ends, even with valid credentials. On S3-compatible storage this is done with versioning and Object Lock.

Before you start

  • An S3-compatible provider that supports Object Lock (not all do; check documentation).
  • Object Lock usually must be enabled when the bucket is created.
  • Background: object storage explained.

Versioning

With versioning, overwriting or deleting an object keeps the previous versions. A delete only adds a "delete marker". This protects against accidents, but someone with enough permissions can still remove old versions.

Object Lock modes

ModeWho can delete before retention endsUse
GovernanceUsers with a special bypass permissionProtection with an emergency override
ComplianceNobody, including the account rootStrongest protection; retention cannot be shortened
Legal holdUntil the hold is removedIndefinite hold independent of retention

Test with governance mode first: compliance mode mistakes cannot be undone and you will pay for storage until retention expires.

Set it up

  1. Create a bucket with Object Lock enabled (this also enables versioning).
  2. Set a default retention, for example governance mode, 30 days.
  3. Add lifecycle rules to delete non-current versions after retention plus a margin, to control costs.
  4. Create a dedicated access key for the backup job allowed only to write (put) objects, not delete or change retention.

Back up to the locked bucket

Tools such as restic, Kopia, rclone and several backup applications support Object Lock or work with versioned buckets. Example with rclone (see rclone backups): use rclone copy rather than sync, so the job never tries to delete.

rclone copy /var/backups s3locked:server-backups/$(hostname) --s3-no-check-bucket

Test restores

  • Regularly restore a backup to a test server.
  • Try deleting a locked object with the backup key to confirm it is refused.
  • Check retention dates on objects in the provider console or with the S3 API.

Frequently asked questions

Does Object Lock encrypt data?

No. Encrypt backups separately (client-side encryption or provider encryption).

What retention should I use?

Long enough to detect an attack, often 14–90 days, balanced against storage cost.

Is a local NAS snapshot immutable too?

Some NAS systems offer immutable snapshots; combine them with an off-site copy.

Next steps

Was this guide helpful?

Still stuck?

Ask MdmHost AI for a quick answer, or open a ticket and our team will take a look. We are here 24/7.