Versioning is a method of keeping multiple modifications/versions of an object in the same bucket. You can use versioning to preserve, retrieve, and restore every version of every object stored in your Amazon S3 bucket.
With versioning, you can easily recover from both unintended user actions, accidental deletes and application failures.
How Versioning works:
In Windows/Linux, if you try to store a file or copy a file with a name of the file which already exists, then you’ll get a pop up, error showing file already exists. Whereas, in versioning .
- If you overwrite an object, it results in a new object version in the bucket. Remember, versioning will not create a new object/file when you overwrite, it’ll simply preserve and suppress the old version, with new version on top. You can always restore the previous version.
In versioning enabled buckets, by default, GET requests will retrieve the most recently written version. In order to retrieve the older version, you’ve to specify the version id of the object.
- If you delete an object, instead of removing it permanently, Amazon S3 inserts a delete marker, which becomes the current object version.
- Each version will take up the individual size of the object. If a 1GB file is uploaded to s3 bucket and then remove the contents of the source file upto 500MB and reuploads it with same name, then the 500MB file will be current version of the object and total object size would 1.5 GB.
- Versioning can only be suspended after enabling, can’t be disabled.
- Important: You can enable additional security for your S3 bucket by enabling Versioning and Multi factor authentication.
With respect to Versioning, Buckets can only be in 3 states.
- unversioned (the default)
- versioning-enabled
- versioning-suspended.