A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://cloud.google.com/storage/docs/using-object-versioning below:

Use Object Versioning | Cloud Storage

Skip to main content Use Object Versioning

Stay organized with collections Save and categorize content based on your preferences.

Overview Usage

This page describes how to enable, disable, and check the status of Object Versioning on a bucket. See Using versioned objects to learn how to list, restore, and delete the objects that are retained by Object Versioning.

Important: There is no default limit on the number of object versions you can have. Each noncurrent version of an object is charged at the same rate as the live version of the object. If you enable versioning, consider using Object Lifecycle Management, which can remove the oldest versions of an object as newer versions become noncurrent. Required roles

To get the permissions that you need to set and manage Object Versioning on a bucket, ask your administrator to grant you the Storage Admin (roles/storage.admin) IAM role on the bucket or the project that contains the bucket. This predefined role contains the permissions required to set and manage Object Versioning for a bucket. To see the exact permissions that are required, expand the Required permissions section:

Required permissions

You might also be able to get these permissions with custom roles.

For information about granting roles on buckets, see Use IAM with buckets. For information about granting roles on projects, see Manage access to projects.

Set Object Versioning on a bucket Console
  1. In the Google Cloud console, go to the Cloud Storage Buckets page.

    Go to Buckets

  2. In the list of buckets, click the name of the bucket for which you want to enable or disable Object Versioning.

  3. Select the Protection tab near the top of the page.

    The current status of Object versioning is found in the Object versioning section.

  4. In the Object versioning section, click the current status to make changes to it.

    The Object versioning dialog appears.

    1. If you're enabling Object Versioning and you want to minimize storage costs, select the Add recommended lifecycle rules to manage version costs checkbox.
  5. Click Confirm.

Command line

Use the gcloud storage buckets update command with the appropriate flag:

gcloud storage buckets update gs://BUCKET_NAME FLAG

Where:

If successful, the response looks similar to the following example:

Updating gs://my-bucket/...
  Completed 1  
Client libraries C++

For more information, see the Cloud Storage C++ API reference documentation.

To authenticate to Cloud Storage, set up Application Default Credentials. For more information, see Set up authentication for client libraries.

The following sample enables Object Versioning on a bucket:

The following sample disables Object Versioning on a bucket:

C#

For more information, see the Cloud Storage C# API reference documentation.

To authenticate to Cloud Storage, set up Application Default Credentials. For more information, see Set up authentication for client libraries.

The following sample enables Object Versioning on a bucket:

The following sample disables Object Versioning on a bucket:

Go

For more information, see the Cloud Storage Go API reference documentation.

To authenticate to Cloud Storage, set up Application Default Credentials. For more information, see Set up authentication for client libraries.

The following sample enables Object Versioning on a bucket:

The following sample disables Object Versioning on a bucket:

Java

For more information, see the Cloud Storage Java API reference documentation.

To authenticate to Cloud Storage, set up Application Default Credentials. For more information, see Set up authentication for client libraries.

The following sample enables Object Versioning on a bucket:

The following sample disables Object Versioning on a bucket:

Node.js

For more information, see the Cloud Storage Node.js API reference documentation.

To authenticate to Cloud Storage, set up Application Default Credentials. For more information, see Set up authentication for client libraries.

The following sample enables Object Versioning on a bucket:

The following sample disables Object Versioning on a bucket:

PHP

For more information, see the Cloud Storage PHP API reference documentation.

To authenticate to Cloud Storage, set up Application Default Credentials. For more information, see Set up authentication for client libraries.

The following sample enables Object Versioning on a bucket:

The following sample disables Object Versioning on a bucket:

Python

For more information, see the Cloud Storage Python API reference documentation.

To authenticate to Cloud Storage, set up Application Default Credentials. For more information, see Set up authentication for client libraries.

The following sample enables Object Versioning on a bucket:

The following sample disables Object Versioning on a bucket:

Ruby

For more information, see the Cloud Storage Ruby API reference documentation.

To authenticate to Cloud Storage, set up Application Default Credentials. For more information, see Set up authentication for client libraries.

The following sample enables Object Versioning on a bucket:

The following sample disables Object Versioning on a bucket:

REST APIs

Once Object Versioning is enabled, each time a live object version is replaced or deleted, that version becomes a noncurrent version.

Check whether Object Versioning is enabled

To check whether Object Versioning is enabled on a bucket:

Console
  1. In the Google Cloud console, go to the Cloud Storage Buckets page.

    Go to Buckets

  2. In the list of buckets, the Object Versioning status of each bucket is found in the Protection column.

If enabled, the text Object versioning appears.

Command line

Use the gcloud storage buckets describe command with the --format flag:

gcloud storage buckets describe gs://BUCKET_NAME --format="default(versioning_enabled)"

Where BUCKET_NAME is the name of the bucket whose status you want to view. For example, my-bucket.

If successful and Object Versioning is enabled, the response looks similar to the following example:

versioning:
  enabled: true

If successful and Object Versioning is not enabled, the response looks similar to the following example:

null
REST APIs JSON API
  1. Have gcloud CLI installed and initialized, which lets you generate an access token for the Authorization header.

  2. Use cURL to call the JSON API with a GET Bucket request:

    curl -X GET \
      -H "Authorization: Bearer $(gcloud auth print-access-token)" \
      "https://storage.googleapis.com/storage/v1/b/BUCKET_NAME?fields=versioning"

    Where BUCKET_NAME is the name of the relevant bucket. For example, my-bucket.

If successful and Object Versioning is enabled, the response looks similar to the following example:

{
  "versioning": {
    "enabled": true
  }
}

If successful and Object Versioning is not enabled, the response looks similar to the following example:

{}
XML API
  1. Have gcloud CLI installed and initialized, which lets you generate an access token for the Authorization header.

  2. Use cURL to call the XML API, with a GET Bucket request and versioning query string parameter:

    curl -X GET \
      -H "Authorization: Bearer $(gcloud auth print-access-token)" \
      "https://storage.googleapis.com/BUCKET_NAME?versioning"

    Where BUCKET_NAME is the name of the relevant bucket. For example, my-bucket.

If successful and Object Versioning is enabled, the response looks similar to the following example:

<VersioningConfiguration>
  <Status>Enabled</Status>
</VersioningConfiguration>

If successful and Object Versioning is not enabled, the response looks similar to the following example:

<VersioningConfiguration/>
What's next

Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2025-08-07 UTC.

[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-07 UTC."],[],[]]


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4