Bucket Recycle Bin
Updated at:2025-11-03
Application scenarios
To enhance data reliability in BOS, users can set up the bucket trash feature to retain deleted data in the bucket trash, making it easier to recover afterward. The user must own the source bucket with FULL_CONTROL permissions and also own the target bucket.
Note:
- Files moved to the bucket trash will continue to be charged until they are completely deleted by the user. For files in the bucket trash, it is recommended that users configure a lifecycle to delete expired files.
- When a user performs an overwrite operation, the old data will not enter the bucket trash
Enable recycle bin
| Parameters | Required or not | Description |
|---|---|---|
| trash_dir | No | Specify the name of the bucket trash directory (optional). By default, the bucket trash directory is named ".trash.\ |
If users want to enable the bucket recycle bin and specify the recycle bin directory, the code is as follows:
Plain Text
1bos_client.put_bucket_trash(bucket_name, trash_dir=".trash")
Note:
- If the bucket trash function has been enabled before, re-enabling it will overwrite the original bucket trash directory name.
- The name of the bucket trash directory can only contain letters, numbers, Chinese characters, underscores (_), hyphens (-), and decimal points (.). Inclusion of '/' will result in an error.
- For buckets with the trash function enabled, deleted objects will be moved to the trash (the full name of an object in the trash is: trashDir + '/' + old object name). Objects in buckets without this function enabled, or in buckets with this function enabled but deleted from the trash will be deleted completely.
- Archive storage class files do not support bucket trash, and it will be deleted directly when the archive storage class files are deleted.
