DEV Community

Merdi Lukongo
Merdi Lukongo

Posted on

Enable Versioning on an S3 Bucket and Never Lose a File Again

Introduction

Have you ever accidentally overwritten or deleted a file in AWS S3? Don't worry - there's a simple feature to save you: S3 Versioning.
In this quick tutorial, I'll show you how to enable versioning on a bucket, test it by uploading multiple versions of the same file, and view or restore previous versions - all for free.

Image description

Prerequisites

An AWS account (Free Tier)
A test file (e.g., test.txt)

Step-by-Step

  1. Create an S3 Bucket Go to the Amazon S3 console

Image description

Click "Create bucket

Image description

Click "Create bucket"

Choose a unique name (e.g., my-versioning-demo-bucket)

Image description

Leave all other settings as default
Click "Create bucket

Image description

  1. Enable Versioning Open your newly created bucket

Image description

Go to the Properties tab

Image description

Scroll down to Bucket Versioning

Image description

  1. Upload a File
    Go to the Objects tab
    Click Upload

  2. What You Get
    You've now enabled automatic version tracking for your S3 bucket.
    Each time you upload a file with the same name, S3 silently keeps the old version - no backup scripts needed.
    Why Use S3 Versioning?

🔁 Restore files deleted or overwritten by mistake
🕓 Roll back to a known good version
🧪 Test changes without fear of data loss

Conclusion
S3 Versioning is a hidden gem that acts like a built-in time machine for your files. Whether you're building apps or hosting a static website, it's a simple and powerful way to stay safe.

Top comments (1)

Collapse
 
merdi_lukongo_0d8287489b7 profile image
Merdi Lukongo

Feel free to ask questions Whenever you want.