---
title: "Versioning"
sidebarTitle: "Versioning"
description: "Enable versioning on a bucket to keep every overwrite and deletion, so you can recover any version after an accidental delete or overwrite."
layout: overview
tags: Preview
tags-style: border
---

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.

<Note>
  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](/contact).
</Note>

## Three states

| State | Overwriting a file | Deleting a file |
| --- | --- | --- |
| Not enabled (default) | Replaces it; the old content can't be recovered | Deletes it permanently; it can't be recovered |
| Enabled | The old content becomes a noncurrent version | Adds a delete marker, which you can undo |
| Suspended | Replaces the copy written while suspended | Removes 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](/bitiful-s4/handbook/object-lock) enabled.

## Enable versioning

<Steps>
  <Step title="Open Versions & protection">
    Go to **Object storage › [Buckets](https://console.bitiful.com/buckets)** › click the bucket name › **Versions & protection**.
  </Step>
  <Step title="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.
  </Step>
  <Step title="Set up automatic cleanup (recommended)">
    Noncurrent versions are kept and billed indefinitely. We recommend also setting up **Expire noncurrent versions** in [Lifecycle](/bitiful-s4/handbook/lifecycle) so they're cleaned up after some days. The system never adds rules for you.
  </Step>
</Steps>

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

<Frame>
  ![The Versions & protection page: the Versioning card shows the number of noncurrent versions, their storage, and delete markers, with the Object Lock card below](/assets/console/bucket-protection-en.webp)
</Frame>

## Version IDs and delete markers

| Concept | Description |
| --- | --- |
| Version ID | Each write gets a unique version ID (`versionId`), the same value as the `x-amz-version-id` header in the write response |
| Current version | The latest version of a file, which regular reads and listings return |
| Noncurrent version | An old version left behind after an overwrite or delete |
| Delete marker | A 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` version | A 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.
<Frame>
  ![The Versions view on the Files page: each file's current and noncurrent versions with version ID, size, and last modified time](/assets/console/object-versions-en.webp)
</Frame>

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

| Action | Effect |
| --- | --- |
| Download this version | Downloads the content of this version |
| Restore as current version | Creates 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 |
| Undelete | Removes the latest delete marker so the version before it becomes current again, without creating a new version |
| Permanently delete this version | Deletes it permanently by version ID; this can't be undone. If you delete the current version, the version before it becomes current |
| Copy version ID | Copies the `versionId` for use in your programs |

## Use the S3 API

| Operation | Usage |
| --- | --- |
| Check the state | GetBucketVersioning returns `Enabled` or `Suspended`; with versioning never enabled, there's no `Status` |
| Enable or suspend | PutBucketVersioning; requires admin permission on the bucket |
| List versions | ListObjectVersions, with list permission. Supports `prefix`, `delimiter` (only `/`), `key-marker`, `version-id-marker`, and `max-keys` |
| Read a version | GetObject or HeadObject with `versionId` |
| Permanently delete a version | DeleteObject with `versionId`, or DeleteObjects with `VersionId` on each item; requires admin permission on the bucket |
| Add a delete marker | DeleteObject without `versionId`; write permission is enough |
| Copy from an old version | Add `?versionId=` to `x-amz-copy-source` in CopyObject |

<Note>
  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.
</Note>

## Pricing and usage

- Noncurrent versions take up storage like current versions and are billed at the [storage price](/prices/basic). 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](/bitiful-s4/handbook/lifecycle).

## Limits

- [Move and rename](/bitiful-s4/features/move-object) 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](/coreix/handbook/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

| Item | S4 behavior |
| --- | --- |
| Listing order | Directory-tree order. When names contain characters smaller than `/` (for example `a!` and `a/b`), it differs from pure lexicographic order |
| Folder objects | Not versioned; they appear as a `null` version in ListObjectVersions |
| MFA delete | Not supported; `MfaDelete=Enabled` returns 501 |
| Buckets not enabled or suspended | Write 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 exist | Versioned buckets return 404 `NoSuchKey`; buckets without versioning still return 400 `InvalidCopySource` |
| `LastModified` | Taken 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 conflicts | Too many concurrent writes to one file may return 503 `SlowDown`. AWS doesn't fail these |
| `x-amz-expiration` | Not returned |

## Related

- [Lifecycle](/bitiful-s4/handbook/lifecycle)
- [Object Lock](/bitiful-s4/handbook/object-lock)
- [Manage files](/bitiful-s4/handbook/objects)
- [S3 API compatibility](/developer/s3/compatibility)
