Object Versioning

Object versioning allows you to restore previous versions of an object, helping you recover data that has been accidentally modified or deleted. It can also be used to retain previous versions of objects for archival purposes and future access

Enabling Versioning for AWS

This parameter can't be set to false, and can't be changed on the standard plan. On previous plans, you can use the following command to enable versioning:
cf update-service <service_instance_name> -c '{"versioning" : true}'

Configuration Parameters

Parameter

Type

Mandatory

Description

Versioning

Boolean

No

Enables versioning for objects within a service instance

Versioning Status

Use the following command to check the versioning status of a service instance:
cf service <service_instance_name> --params

Permissions

On AWS based landscapes, below is the list of additional permissions given to a service binding user:

  • s3:ListBucketVersions

  • s3:DeleteObjectVersion

  • s3:DeleteObjectVersionTagging

  • s3:GetObjectVersion

  • s3:GetObjectVersionAcl

  • s3:GetObjectVersionTagging

  • s3:GetObjectVersionTorrent

  • s3:PutObjectVersionAcl

  • s3:PutObjectVersionTagging

For more information, see Policy actions for Amazon S3Information published on non-SAP site.

Object versioning is applicable on all the objects residing in the bucket. Amazon doesn't provide a way to selectively enable the feature on a specific folder or an object.

Impact on the Cost

Each version of an object is treated as a separate stored object. The total storage cost is therefore the sum of the storage costs for all versions.

Normal storage and data transfer rates apply to each version. For example, if you have three versions of a blob stored, you are charged for all three complete objects.

Example on How to Use Object Versioning Feature

The following example shows how to retrieve and process object versions from an Amazon S3 bucket:

// Retrieve the list of versions. If the bucket contains more versions
// than the specified maximum number of results, Amazon S3 returns
// one page of results per request.
ListVersionsRequest request = new ListVersionsRequest().withBucketName(bucketName).withMaxResults(2);
VersionListing versionListing = s3Client.listVersions(request);
int numVersions = 0, numPages = 0;
while (true) {
  numPages++;
  for (S3VersionSummary objectSummary : versionListing.getVersionSummaries()) {
    System.out.printf("Retrieved object %s, version %s\n", objectSummary.getKey(), objectSummary.getVersionId());
    numVersions++;
  }
  // Check whether there are more pages of versions to retrieve. If there are, retrieve them. Otherwise, exit the loop.
  if (versionListing.isTruncated()) {
    versionListing = s3Client.listNextBatchOfVersions(versionListing);
  } else {
    break;
  }
}

How to Restore an Earlier Version of an Object?

  • In order to restore to the immediate previous version of an object, you may permanently delete the current version of the object.

  • In order to restore to an older version of an object, you can simply copy the previous version into the same bucket. The copied object would become the current version and all the earlier versions would remain preserved.