Versioning

Versioning ensures security of objects in a bucket by preventing unpredictable loss due to accidental object deletions or overwrites.

Versioning Status

The status of versioning can be disabled, enabled, or suspended.

Once the versioning status of a bucket is enabled, it cannot be restored to the disabled status. However, you can set the versioning status of the bucket to suspended.

Each time an object is created, OBS assigns a version number to the object. The version number generation rule varies with the versioning state of the bucket.

  • When the versioning state of a bucket is Disabled or Suspended, the version number of a newly created object is null.
  • When the versioning state of a bucket is Enabled, the version number of a newly created object is a randomly generated 32- to 48-byte character string and it is globally unique.

Data Protection Mechanism

Any object saved in OBS, unless being deleted or overwritten by another object with the same name, can always be obtained. However, sometimes you may accidentally delete or overwrite an object and data cannot be restored. Or you may want to save copies for data in different periods and keep a unified object name for such copies. In these two scenarios, you are advised to enable the versioning feature of the bucket.

Table 1 Rules for deleting and overwriting objects in different versioning states

Versioning Status

Deleting an Object

Overwriting an Object

Disabled

The object is directly deleted and cannot be obtained.

The object is directly overwritten and cannot be restored. Only the new object can be obtained.

Enabled

A delete marker is generated for the object. The delete marker also carries a globally unique version number. Historical versions are not affected.

NOTE:

No matter whether the object has a historical version, OBS always generates a delete marker, indicating that a deletion has been performed at this time.

In this case,

If you try to obtain an object without specifying the version number, the system displays a message indicating that the object does not exist.

If you try to obtain an object with the version number specified, the target object can be obtained.

A new version is generated for this object, and the historical version is not affected.

In this case,

if you try to obtain an object without specifying the version number, the object of the latest version is returned.

If you try to obtain an object with the version number specified, the target object can be obtained.

Suspended

A delete marker whose version number is null is generated for this object. If an object or delete marker whose version number is null already exists, it will be overwritten by the new delete marker. Objects or delete markers whose version numbers are not null are not affected.

NOTE:

No matter whether the object has a historical version, OBS always generates a delete marker, indicating that a deletion has been performed at this time.

In this case,

if you try to obtain an object without specifying the version number, the system displays a message indicating that the object does not exist.

If you try to obtain an object with the version number specified, the target object can be obtained.

An object whose version number is null is generated for this object. If an object or delete marker whose version number is null already exists, it will be overwritten by the new delete marker. Objects or delete markers whose version numbers are not null are not affected.

In this case,

if you try to obtain an object without specifying the version number, the object of the latest version is returned.

If you try to obtain an object with the version number specified, the target object can be obtained.

For ease of understanding, the version numbers in the following figures are all presented by character strings shorter than actual ones.

As shown in the following figure, when versioning is enabled and an object is repeatedly created, a new version number is generated upon each creation.

As shown in the following figure, when versioning is enabled and an object is deleted, the object is not actually deleted. Instead, a delete marker is generated to indicate that the current version of the object is deleted.

You can view delete markers in a bucket by calling Listing Objects in a Bucket (listing multi-version objects). When the latest version of an object is deleted and the object is uploaded again. The delete marker does not disappear. Instead, it is stored in OBS as a historical version.

As shown in the following figure, when versioning is suspended and an object is created. Historical versions of this object are retained, and the version number of the new object is null. If you create the object again, the latest object with the version null automatically overwrites the previous null version.

Deleting a Specified Version

Object version numbers are allocated by OBS. Therefore, you cannot specify the version number when creating an object. However, when you download or delete an object, you can specify the version number for such operations.

The following figure shows the changes of a multi-version object in a bucket after a specified version of the object is deleted:

If a specified version of an object is deleted by specifying the version number, OBS does not retain the specified historical version of the object and removes it from the object historical version list.

If the object of version 00003 shown in the figure is deleted, the latest version of the object becomes 00001. In this case, if you try to obtain the object without specifying the version number, the object of version 00001 is obtained.

Differences Between the Suspended State and the Disabled State

In both the suspended and disabled states, the version number of a newly created object is null and it overwrites the original null version of the object regardless of whether the original null version is generated in the suspended or disabled state. That is, OBS saves only one null version for an object.

The difference lies in the methods of handling deletion operations. In the suspended state, if an object is deleted, a delete marker whose version number is null is generated no matter whether the object has a historical version. However, in the disabled state, the delete marker is not generated.

After versioning is enabled, all historical versions of an object are stored and they occupy storage space. Storage fees of such historical versions will be charged by OBS. Exercise caution when enabling versioning to avoid extra storage fees.