Skip to content

Versioning

Preview

With versioning enabled, overwriting a file keeps the old content as a noncurrent version, and deleting a file only adds a delete marker, so the original data is still there. After an accidental delete, an accidental overwrite, or a malicious change, you can recover any version from Versions in the console.

Versioning is in preview. It is live on the storage side, and the console entry is rolling out account by account: accounts that don't have it yet won't see the Versions & protection tab on the bucket page. To use it early, please contact support.

Three states

StateOverwriting a fileDeleting a file
Not enabled (default)Replaces it; the old content can't be recoveredDeletes it permanently; it can't be recovered
EnabledThe old content becomes a noncurrent versionAdds a delete marker, which you can undo
SuspendedReplaces the copy written while suspendedRemoves the copy written while suspended and leaves a delete marker
  • Once enabled, a bucket can't go back to "not enabled". You can only suspend it, and you can resume at any time.
  • Suspending doesn't delete any noncurrent versions. Versions created while versioning was enabled are kept and billed as usual.
  • Versioning can't be suspended in a bucket with Object Lock enabled.

Enable versioning

Open Versions & protection

Go to Object storage › Buckets › click the bucket name › Versions & protection.

Enable it

On the Versioning card, click Enable versioning, read the notice, and confirm. It takes effect immediately, and every later overwrite and delete keeps the old data.

To suspend, click Suspend versioning on the same card. For a suspended bucket, click Resume versioning.

The Versions & protection page: the Versioning card shows the number of noncurrent versions, their storage, and delete markers, with the Object Lock card below

Version IDs and delete markers

ConceptDescription
Version IDEach write gets a unique version ID (versionId), the same value as the x-amz-version-id header in the write response
Current versionThe latest version of a file, which regular reads and listings return
Noncurrent versionAn old version left behind after an overwrite or delete
Delete markerA marker added when you delete a file without a version ID; its size is 0. When the latest entry is a delete marker, the file disappears from the list, but all earlier versions are still there
null versionA version written before versioning was enabled, or while it was suspended. Its version ID is null

Folder objects (keys ending in /) aren't versioned and always appear as a null version.

Recover files in the console

On the bucket's Files page, click Versions. The list then shows every version and delete marker of each file; click it again to go back to the normal list.

The Versions view on the Files page: each file's current and noncurrent versions with version ID, size, and last modified time

For each version, you can do the following from the … menu on its row:

ActionEffect
Download this versionDownloads the content of this version
Restore as current versionCreates a new current version with this version's content and keeps all existing versions. For versions larger than 5 GiB, use an S3-compatible tool to copy the version onto the same path
UndeleteRemoves the latest delete marker so the version before it becomes current again, without creating a new version
Permanently delete this versionDeletes it permanently by version ID; this can't be undone. If you delete the current version, the version before it becomes current
Copy version IDCopies the versionId for use in your programs

Use the S3 API

OperationUsage
Check the stateGetBucketVersioning returns Enabled or Suspended; with versioning never enabled, there's no Status
Enable or suspendPutBucketVersioning; requires admin permission on the bucket
List versionsListObjectVersions, with list permission. Supports prefix, delimiter (only /), key-marker, version-id-marker, and max-keys
Read a versionGetObject or HeadObject with versionId
Permanently delete a versionDeleteObject with versionId, or DeleteObjects with VersionId on each item; requires admin permission on the bucket
Add a delete markerDeleteObject without versionId; write permission is enough
Copy from an old versionAdd ?versionId= to x-amz-copy-source in CopyObject

Sub-user AccessKeys can upload files (which creates versions automatically), delete files without a version ID (which adds a delete marker and requires write permission), list versions, read specific versions, and read the versioning, lifecycle, and Object Lock settings.

The following require admin permission on the bucket, which sub-user AccessKeys don't have, so do them in the console: enabling and suspending versioning, setting and deleting lifecycle rules, enabling Object Lock and setting the default retention, legal hold, setting compliance retention, permanently deleting by version ID (including items with a version ID in a batch delete), and bypassing governance mode.

Pricing and usage

  • Noncurrent versions take up storage like current versions and are billed at the storage price. Delete markers take no space.
  • The bucket's Versions & protection page shows the number of noncurrent versions, the space they use, and the number of delete markers. Space used by noncurrent versions counts toward storage usage, but isn't included in the capacity shown in the bucket header.
  • When files are overwritten often, noncurrent versions grow quickly. Use the Expire noncurrent versions rule in Lifecycle.

Limits

  • Move and rename doesn't work in buckets that have ever had versioning enabled and returns 501.
  • Before deleting a bucket, permanently delete all versions and delete markers, or the request returns 409 BucketNotEmpty.
  • versionId works only in signed requests and presigned URLs. Anonymous and CDN requests with versionId return 403.
  • versionId can't be combined with styles or CoreIX processing parameters, and returns 400 InvalidRequest.
  • If one file receives too many concurrent writes and retries after conflicts still fail, the request returns 503 SlowDown, which SDKs retry automatically.

Differences from AWS

ItemS4 behavior
Listing orderDirectory-tree order. When names contain characters smaller than / (for example a! and a/b), it differs from pure lexicographic order
Folder objectsNot versioned; they appear as a null version in ListObjectVersions
MFA deleteNot supported; MfaDelete=Enabled returns 501
Buckets not enabled or suspendedWrite responses don't include x-amz-version-id, and reads of files that existed before versioning was enabled don't include x-amz-version-id: null
Copy source doesn't existVersioned buckets return 404 NoSuchKey; buckets without versioning still return 400 InvalidCopySource
LastModifiedTaken from when the request started, while version order follows commit order. With slow large uploads or concurrent writes to the same file, the latest version's LastModified may be earlier than a noncurrent version's
Concurrent write conflictsToo many concurrent writes to one file may return 503 SlowDown. AWS doesn't fail these
x-amz-expirationNot returned