Alibaba Cloud Object Storage Service (OSS) is a platform that stores massive data and supports a wide range of applications. When you use OSS, you will inevitably encounter problems with accidental and improper operations, program bugs, overwriting, and issues that result in the loss of important data. Data loss can cause emergencies with severe consequences. In serious situations, you could even lose your job. Every year, lots of data is deleted accidentally on OSS. This is why we developed a versioning feature that allows you to retrieve previous data versions to reverse accidental deletion.
When versioning is enabled for a bucket, OSS assigns a unique ID for each version of all objects in the bucket. The content and ACL of existing objects in the bucket remain unchanged. Versioning prevents unintended overwrites and deletions on your data. You can also use versioning to retrieve a previous version of an object and recover the previous version as the current version at any time. For more details about the versioning feature, please see the introduction on the official website.
As shown in the preceding figure, when you perform the PutObject operation to upload the same object with the key of example.jpg, OSS assigns a new unique version ID of 222222 to the object and stores this version as the current version in the bucket. In this case, version 111111 becomes a previous version. When you perform the PutObject operation to upload the same object with the key of example.jpg again, OSS assigns a new unique version ID of 333333 to the object and stores this version as the current version in the bucket. Then, versions 111111 and 222222 become previous versions.
You can enable versioning in two ways:
By enabling versioning for an existing bucket, you can configure versioning for existing OSS data to protect historical data.
When versioning is enabled, you can navigate to the Show Previous Versions of the Files box in the console and select a previous version, as shown in the following figure.
In the console, if you upload an object with the same name as an existing object, multiple versions are generated. Among these versions, the one marked (Latest Version) indicates the latest object with the most recent update time.
After you enable versioning, deleting an object does not delete the object completely; it inserts a deletion marker, as shown in the following figure.
After an object is "deleted" this way, it is not displayed in the console unless you select Show Previous Versions of the Files. The object is not deleted completely and can be restored if necessary.
If versioning is enabled, previous versions of data are not deleted. Therefore, you can restore historical data yourself by going through the procedure shown in the following figure.
Therefore, when versioning is enabled, you can restore data without any assistance. This means you do not have to worry about the consequences of accidental operations, program bugs, overwriting, or other errors.
The OSS console provides an easy way to restore individual objects. However, this is an inefficient and time-consuming method if you need to restore a large number of files when a directory is deleted. To address this need, OSS provides the ossutil tool to perform multiple data repairs and improve repair efficiency.
The overall process of this scenario is shown in the preceding figure. The relevant command is shown below:
$) ./ossutilmac64 ls oss://test-jsj-versioning/prefix/ --all-versions
| grep -rn "true true oss://"
| awk -F ' ' '{drcmd=("./ossutilmac64 rm " $10" --version-id "$7);print drcmd}'
| sh
Here, deletion markers display "true true," so you only need to delete the markers that match the prefix to restore the corresponding objects.
The overall process of this scenario is shown in the preceding figure. The relevant command is shown below:
./ossutilmac64 ls oss://test-jsj-versioning/pre- --all-versions
| awk '{(dtime=($1" "$2" "$3" "$4));
if ((dtime>="2020-06-16 16:55:05 +0800 CST")
&& (dtime<="2020-06-16 16:55:40 +0800 CST")) print}'
| grep -rn "true true oss://"
| awk -F ' ' '{drcmd=("./ossutilmac64 rm " $10" --version-id "$7);print drcmd}'
| sh
You only need to delete the markers that match the time range to restore the corresponding objects.
The overall process of this scenario is shown in the preceding figure. The relevant command is shown below:
for i in cat file_list;
do
./ossutilmac64 ls oss://test-jsj-versioning/$i --all-versions
| grep -rn "true true oss://"
| awk -F ' ' '{drcmd=("./ossutilmac64 rm " $10" --version-id "$7);print drcmd}'
| sh;
done
You only need to traverse the repair list file and delete the listed deletion markers to restore the corresponding objects.
After you enable versioning, previous versions are retained even when an object is deleted, adding to your storage costs. You can adopt a solution that combines versioning and lifecycle management to enjoy the benefits of versioning at a lower cost, as shown in the following figure:
In the lifecycle configuration, you can set policies for current versions (with deletion markers) and previous versions to convert the objects to a specified type after a certain time. This will reduce storage costs. You can also set policies to delete objects after a specified number of days. For example, if you set a policy to delete objects after 30 days, the corresponding data can only be restored within 30 days, similar to the retention period of a recycle bin.
Accidental data deletion is a serious problem that is difficult to avoid. After enabling the OSS versioning feature, you will enjoy an effective data protection solution. After combining versioning and lifecycle management, you can set data retention policies to reduce your storage costs while protecting your data. We hope you will take advantage of this feature soon to protect all of your valuable data.
57 posts | 12 followers
FollowDikky Ryan Pratama - May 22, 2023
Alibaba Clouder - January 15, 2021
Alibaba Clouder - March 15, 2019
Alibaba Cloud Vietnam - July 12, 2023
JDP - March 25, 2022
Nick Patrocky - January 30, 2024
57 posts | 12 followers
FollowAn encrypted and secure cloud storage service which stores, processes and accesses massive amounts of data from anywhere in the world
Learn MoreHelp enterprises build high-quality, stable mobile apps
Learn MoreProvides scalable, distributed, and high-performance block storage and object storage services in a software-defined manner.
Learn MoreProvides comprehensive quality assurance for the release of your apps.
Learn MoreMore Posts by Alibaba Cloud Storage