The revert-versioning command is used to recover an object in a versioned bucket to the most recent previous version by deleting the delete marker of which the IS-LATEST value is true.

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 versioning, see Overview.
  • For more information about delete markers, see Delete marker.

Command syntax

./ossutil revert-versioning oss://bucket[/prefix] [--encoding-type encodeType] [-r] [--start-time startTime] [--end-time endTime]  [--include include-pattern] [--exclude exclude-pattern] [--payer requester]

In a versioned bucket, you can run this command to recover an deleted object to the latest previous version by deleting the latest delete marker of the object.

Examples

  • Recover a single deleted object to the most recent previous version
    ./ossutil revert-versioning oss://bucket1/test.txt
  • Recover a deleted object with a specified prefix to the most recent previous version
    ./ossutil revert-versioning oss://bucket1/prefix -r
  • Recover all deleted objects in the bucket to the most recent previous version
    ./ossutil revert-versioning oss://bucket1  -r
  • Recover objects deleted within a specified time period to the most recent previous version

    For example, recover objects that are deleted within the time period from June 16, 2020 16:22:58 UTC+8 to June 16, 2020 16:39:38 UTC+8

    ./ossutil revert-versioning oss://bucket1/test -r --start-time 1592295778 --end-time 1592296778
    • --start-time: a UNIX timestamp. If you specify this option in the command, objects deleted before this time are not recovered.
    • --end-time: a UNIX timestamp. If you specify this option in the command, objects deleted after this time are not recovered.
  • Recover deleted objects that match the specified conditions to the latest version
    When you recover deleted objects, you can set the --include and --exclude parameters to select objects that meet specified conditions. For more information, see Common options.
    • Recover all deleted TXT objects to the latest version
      
      ./ossutil revert-versioning oss://bucket1 --include "*.txt" -r
    • Recover all deleted non-JPG objects to the latest version
      
      ./ossutil revert-versioning oss://bucket1 --exclude "*.jpg" -r

Common options

The following table describes the options that you can add to the revert-versioning command.
Parameter Description
-r, --recursive Recursively performs operations on objects in a bucket. If this option is specified, commands that support this option will perform operations on all objects within buckets that meet the specified conditions. If this option is not specified, the commands will perform operations only on the specified object.
--start-time A UNIX timestamp. If you specify this option in the command, objects deleted before this time are not recovered.
--end-time A UNIX timestamp. If you specify this option in the command, objects deleted after this time are not recovered.
--include Includes objects that match a specified string, such as *.jpg.
--exclude Excludes objects that match a specified string, such as *.txt.
--encoding-type Specifies the method used to encode the object name. If this option is specified, the value must be url. If this option is not specified, the object name is not encoded. Bucket names cannot be URL-encoded.
--payer Specifies the payer of the request. If pay-by-requester is enabled, you can set this option to requester.
--loglevel Specifies the log level. The default value is null and specifies that no log file is generated. Valid values:
  • info: generates prompt logs.
  • debug: generates detailed logs that contain HTTP request and response information.
--proxy-host Specifies the URL of the proxy server. HTTP, HTTPS, and SOCKS5 proxies are supported. Examples: http://120.79. **.**:3128 and socks5://120.79. **. **:1080.
--proxy-user Specifies the username of 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.