The bucket-versioning command is used to configure versioning for a bucket or query versioning configurations.

Note
  • The commands described in this topic apply to Linux. To use the commands in other systems, replace ./ossutil in the command with the actual executable program name. For example, you can use the help command in 32-bit Windows systems by running ossutil32.exe help.
  • For more information about bucket versioning, see Overview.

Command syntax

  • Enable/Suspend bucket versioning
    ./ossutil bucket-versioning --method put oss://bucket versioning_parameter
    When the --method option is set to put, the versioning_parameter parameter can only be set to enabled or suspended.
    • Versioning is enabled when the versioning_parameter parameter is set to enabled,
    • Versioning is suspended when the versioning_parameter parameter is set to suspended.
  • Query versioning configurations for a bucket
    ./ossutil bucket-versioning --method get oss://bucket

Examples

  • Enable versioning for a bucket
    ./ossutil bucket-versioning --method put oss://bucket1 enabled
  • Suspend versioning for a bucket
    ./ossutil bucket-versioning --method put oss://bucket1 suspended
  • Query versioning configurations for a bucket
    ./ossutil bucket-versioning --method get oss://bucket1
    bucket versioning status:Suspended
    Note A bucket can be in any of the following versioning states:
    • Enabled: indicates that versioning is enabled for the bucket. When an object in this state is deleted or overwritten, an object version is generated. For more information, see Enable versioning.
    • Suspended: indicates that versioning is suspended for the bucket. When versioning is suspended, you can still use the version ID to download, copy, or delete previous versions of an object. When you overwrite or delete an object, a unique version whose ID is null is generated. If the current version of the object is null, a new null version is generated to replace the current version. For more information, see Suspend versioning.
    • Null: indicates that versioning has never been enabled for the bucket. If you have enabled versioning for a bucket, the versioning state of the bucket cannot be changed to Null.

Common options

The following table describes the options you can add to the bucket-versioning command.
Option Description
--method Specifies the HTTP request method. Valid values:
  • put: enables or suspends versioning.
  • get: queries versioning configurations.
--loglevel Specifies the log level. The default value is null, indicating that no log files are generated. Valid values:
  • info: generates prompt logs.
  • debug: generates detailed logs that contain corresponding HTTP request and response information.
--proxy-host Specifies the URL of the proxy server. HTTP, HTTPS, and SOCKS5 proxies are supported. An example of the URL is http://120.79. **.**:3128 or socks5://120.79. **. **:1080.
--proxy-user Specifies the username for the proxy server. The default value is null.
--proxy-pwd Specifies the password for the proxy server. The default value is null.
Note For more information about common options, see View all supported options.