After versioning is enabled, you can recover data lost due to accidental operations or application failures using the following methods:
- Copy a specific historical object version and upload it to the bucket, making it the current version.
- Permanently delete a delete marker so that the most recent historical version becomes the current version.
Prerequisites
- Versioning is enabled for the bucket that stores the objects.
- To recover data by permanently deleting a delete marker, ensure that the bucket contains at least one historical version of the same object without a delete marker.
Recovering a Deleted Object by Permanently Deleting a Delete Marker
Deleting an object from a versioning-enabled bucket does not remove the object itself. Instead, OBS inserts a delete marker to indicate that the latest version of the object is in the deleted state, while the previous current version becomes a historical version.
You can remove a delete marker using OBS Console, APIs, SDKs, or obsutil.
Using OBS Console
- In the navigation pane of OBS Console, choose Buckets.
- In the bucket list, click the desired bucket. The Objects page is displayed.
- Enable Historical Versions above the object list.
- In the Last Modified column, locate the object with Delete Marker and click Permanently Delete in the Operation column.
You can also select all objects with Delete Marker and click Permanently Delete above the object list to recover them in a batch.
Figure 1 Recovering a single object
Figure 2 Batch recovering objects
- In the displayed dialog box, click OK.
The delete marker disappears, and the Historical Version label next to the last modification time of the most recent historical version is removed. This indicates that the most recent historical version has become the current version, meaning the object has been recovered.
Using APIs
- List object versions in the bucket to obtain the version ID of the object that has a delete marker. In the response body, the object version that contains the DeleteMarker parameter is the delete marker, and its VersionId parameter indicates the version ID of that delete marker.
- Delete the object by specifying the version ID obtained in 1.
Using SDKs
- List object versions in the bucket to obtain the version ID of the object that has a delete marker. In the response body, the object version that contains the DeleteMarker parameter is the delete marker, and its VersionId parameter indicates the version ID of that delete marker. The SDKs for listing object versions are as follows.
- Delete the object by specifying the version ID obtained in 1. The SDKs for deleting an object are as follows.
Using the CLI Tool - obsutil
- List object versions in the bucket to obtain the version ID of the object that has a delete marker. In the response, VersionId under DeleteMarker list indicates the version ID of the delete marker.
- Delete the object by specifying the version ID obtained in 1. The command for deleting an object is as follows:
Command Line Structure
- Windows
obsutil rm obs://bucket/key [-f] -versionId=xxx [-fr] [-o=xxx] [-config=xxx] [-e=xxx] [-i=xxx] [-k=xxx] [-t=xxx]
- macOS or Linux
./obsutil rm obs://bucket/key [-f] -versionId=xxx [-fr] [-o=xxx] [-config=xxx] [-e=xxx] [-i=xxx] [-k=xxx] [-t=xxx]
Examples
In Windows, run
obsutil rm obs://test-bucket/data_0001.txt -versionId=G001119ED32CD9F700004011024A1A22 to delete the delete marker of the
data_0001.txt object in the
bucket-test bucket.
G001119ED32CD9F700004011024A1A22 is the version ID of the delete marker.
obsutil ls obs://test-bucket/data_0001.txt -v
Start at 2026-06-17 01:23:35.2387286 +0000 UTC
Listing versioning objects .
Versioning Object list:
Key VersionId LastModified Size StorageClass ETag
obs://test-bucket/data_0001.txt
G001119ED0A0BF6800004017005E42D5 2026-06-16T13:30:56Z 0B standard "d41d8cd98f00b204e9800998ecf8427e"
DeleteMarker list:
Key VersionId LastModified StorageClass
obs://test-bucket/data_0001.txt
G001119ED32CD9F700004011024A1A22 2026-06-17T01:23:12Z standard
Total size of prefix [data_0001.txt]: 0B
Folder number: 0
Versioning file number: 1
DeleteMarker number: 1
obsutil rm obs://test-bucket/data_0001.txt -versionId=G001119ED32CD9F700004011024A1A22
Start at 2026-06-17 01:23:56.7597831 +0000 UTC
Do you want delete object [data_0001.txt] in the bucket [test-bucket]? Please input (y/n) to confirm:
y
Delete object [data_0001.txt] with version id [G001119ED32CD9F700004011024A1A22] in the bucket [test-bucket] successfully, cost [187], request id [0000019ED32D911E4015141E86F59409]
obsutil ls obs://test-bucket/data_0001.txt -v
Start at 2026-06-17 01:24:03.869759 +0000 UTC
Listing versioning objects .
Versioning Object list:
Key VersionId LastModified Size StorageClass ETag
obs://test-bucket/data_0001.txt
G001119ED0A0BF6800004017005E42D5 2026-06-16T13:30:56Z 0B standard "d41d8cd98f00b204e9800998ecf8427e"
Total size of prefix [data_0001.txt]: 0B
Folder number: 0
Versioning file number: 1
DeleteMarker number: 0 Parameter Description
| Parameter | Optional or Mandatory | Description |
| bucket | Mandatory | The bucket name |
| key | Mandatory for deleting a single object. Optional for deleting objects in batches. | The name of the object to be deleted, or the name prefix of the objects to be deleted in batches NOTE: If this parameter is left blank when deleting objects in batches, all objects in the bucket are deleted. Use this parameter with caution. |
| fr | Optional for deleting a single object (additional parameter) | Generates an operation result file when deleting an object. |
| f | Optional (additional parameter) | Runs in force mode. Use this parameter with caution. |
| versionId | Optional for deleting a single object (additional parameter) Mandatory for deleting object versions | The version ID of the object to be deleted. |
| r | Mandatory for deleting objects in batches (additional parameter) | Deletes objects in batches based on a specified object name prefix. CAUTION: When you batch delete objects, all objects with the specified prefix will be deleted. |
| j | Optional for deleting objects in batches (additional parameter) | The maximum number of concurrent tasks for deleting objects in batches. The default value is the value of defaultJobs in the configuration file. NOTE: The tool ensures that this value is at least 1. |
| v | Optional for deleting objects in batches (additional parameter) | Deletes versions of an object and the delete markers in batches based on a specified object name prefix. |
| o | Optional (additional parameter) | The folder that stores the result files. After the command is executed, result files (possibly success and failure files) will be created in the specified folder. The default value is .obsutil_output, a subfolder in the user's home directory where obsutil commands are executed. NOTE: - A result file should be named as follows: rm_{succeed | failed}_report_time_TaskId.txt.
- By default, the maximum size of a single result file is 30 MB and the maximum number of result files that can be retained is 1,024. You can set the maximum size and number by configuring recordMaxLogSize and recordBackups in the configuration file.
- If there are multiple folders and files and you need to confirm the details of a failed task, refer to the failure result file cp_failed_report_time_TaskId.txt in the result folder and the log files in the log path.
|
| bucket-cname | Optional (additional parameter) | The user-defined domain name bound to the bucket NOTE: This parameter is only supported by obsutil 5.7.9 and later. |
| config | Optional (additional parameter) | The user-defined configuration file for executing the current command. For details about parameters that can be configured, see Configuration Parameters. |
| e | Optional (additional parameter) | The endpoint |
| i | Optional (additional parameter) | The user's AK |
| k | Optional (additional parameter) | The user's SK |
| t | Optional (additional parameter) | The user's security token |
Response
| Field | Description |
| Parallel | The parameter -p in the request |
| Jobs | The parameter -j in the request |
| Threshold | The parameter -threshold in the request |
| PartSize | The parameter -ps in the request |
| Exclude | The parameter -exclude in the request |
| Include | The parameter -include in the request |
| TimeRange | The parameter -timeRange in the request |
| VerifyLength | The parameter -vlength in the request |
| VerifyMd5 | The parameter -vmd5 in the request |
| CheckpointDir | The parameter -cpd in the request |
| OutputDir | The parameter -o in the request |
| ArcDir | The parameter -arcDir in the request |
| Succeed count | The number of successful tasks |
| Failed count | The number of failed tasks |
| Skip count | The number of tasks that are skipped during incremental upload, download, or copy, and synchronous upload, download, or copy. NOTE: Skipped tasks are recorded into successful tasks. |
| Warning count | The number of tasks that are executed successfully but contain warnings. NOTE: - The task for which a warning is generated may be a failure or a success, which needs to be further determined according to the corresponding result list.
- The number of tasks that generate warnings is independent of the number of successful or failed tasks. The total number of tasks is the number of successful tasks plus the number of failed tasks.
|
| Succeed bytes | The number of bytes that are successfully uploaded or downloaded. |
| max cost | The maximum duration of all tasks, in ms |
| min cost | The minimum duration of all tasks, in ms |
| average cost | The average duration of all tasks, in ms |
| average tps | The average number of tasks completed per second |
| Task id | The unique ID of an operation, which is used to search for the result file generated for a batch task |