View a markdown version of this page

Retrieving object versions from a versioning-enabled bucket - Amazon Simple Storage Service

Retrieving object versions from a versioning-enabled bucket

Versioning in Amazon S3 is a way of keeping multiple variants of an object in the same bucket. A simple GET request retrieves the current version of an object. The following figure shows how GET returns the current version of the object, photo.gif.

How GET returns the current version of the object.

To retrieve a specific version, you have to specify its version ID. The following figure shows that a GET versionId request retrieves the specified version of the object (not necessarily the current one).

How a GET versionId request retrieves the specified version of the object.

You can retrieve object versions in Amazon S3 using the console, AWS SDKs, or REST API.

Note

To access object versions older than 300 versions, you must use the AWS CLI or the object's URL.

You can restore a previous version of an object using the Amazon S3 console by deleting the current version. Deleting the current version makes the previous version the new current version.

To restore a previous version by deleting the current version
  1. Sign in to the AWS Management Console and open the Amazon S3 console at https://console.aws.amazon.com/s3/.

  2. In the Buckets list, choose the name of the bucket that contains the object.

  3. In the Objects list, choose the name of the object.

  4. Choose Versions.

    Amazon S3 shows all the versions for the object.

  5. Select the check box next to the Version ID of the current (latest) version that you want to delete.

  6. Choose Delete.

  7. In the Delete objects dialog box, enter permanently delete, and then choose Delete objects.

    After you delete the current version, the previous version becomes the current version.

To download a previous version
  1. Sign in to the AWS Management Console and open the Amazon S3 console at https://console.aws.amazon.com/s3/.

  2. In the Buckets list, choose the name of the bucket that contains the object.

  3. In the Objects list, choose the name of the object.

  4. Choose Versions.

    Amazon S3 shows all the versions for the object.

  5. Select the check box next to the Version ID for the versions that you want to retrieve.

  6. Choose Actions, choose Download, and save the object.

You also can view, download, and delete object versions in the object overview panel. For more information, see Viewing object properties in the Amazon S3 console.

Note

To copy a previous version in place (making it the new current version), use the AWS CLI or AWS SDKs — this approach isn't available in the Amazon S3 console. For an example, see the AWS CLI tab.

Important

You can undelete an object only if it was deleted as the latest (current) version. You can't undelete a previous version of an object that was deleted. For more information, see Retaining multiple versions of objects with S3 Versioning.

The examples for uploading objects in nonversioned and versioning-enabled buckets are the same. However, for versioning-enabled buckets, Amazon S3 assigns a version number. Otherwise, the version number is null.

For examples of downloading objects using AWS SDKs for Java, .NET, and PHP, see Downloading objects.

For examples of listing the version of objects using AWS SDKs for .NET and Rust, see List the version of objects in an Amazon S3 bucket.

To retrieve a specific object version
  1. Set versionId to the ID of the version of the object that you want to retrieve.

  2. Send a GET Object versionId request.

Example— Retrieving a versioned object

The following request retrieves version L4kqtJlcpXroDTDmpUMLUo of my-image.jpg.

GET /my-image.jpg?versionId=L4kqtJlcpXroDTDmpUMLUo HTTP/1.1 Host: bucket.s3.amazonaws.com Date: Wed, 28 Oct 2009 22:32:00 GMT Authorization: AWS AKIAIOSFODNN7EXAMPLE:0RQf4/cRonhpaBX5sCYVf1bNRuU=

You can retrieve just the metadata of an object (not the content). For information, see Retrieving the metadata of an object version.

For information about restoring a previous object version, see Restoring previous versions.