azure blob_如何在Azure Blob存储中恢复意外删除

azure blob

This article explains one of the important data protection features in Azure Blob Storage – Soft Delete, which helps to recover data that is accidentally deleted in blobs or blob snapshots.

本文介绍了Azure Blob存储中的一项重要数据保护功能–软删除,它有助于恢复在Blob或Blob快照中意外删除的数据。

Cloud has taken almost every Industry by storm and businesses are actively adopting cloud services for its elasticity, cost savings, and on-demand services. Azure BLOB (Binary Large Object) Storage is one such service by Microsoft that lets you store large amounts of unstructured data – including text, documents, audio, images, videos or binary.

云几乎席卷了每个行业,企业因其弹性,节省成本和按需服务而积极采用云服务。 Azure BLOB(二进制大对象)存储是Microsoft提供的一种此类服务,可让您存储大量非结构化数据-包括文本,文档,音频,图像,视频或二进制文件。

Organizations are creating and storing large amounts of data at unprecedented volumes and speed, and with this rapidly growing data and democratization of data, there are chances of unintended deletes. Fortunately, the soft delete feature in Azure Blob Storage comes to the rescue and helps blob storage users recover such data. It prevents accidental data loss and offers data protection to your application.

组织正在以前所未有的数量和速度创建和存储大量数据,并且随着这种快速增长的数据和数据的民主化,有可能意外删除。 幸运的是,Azure Blob存储中的软删除功能可以挽救并帮助Blob存储用户恢复此类数据。 它可以防止意外数据丢失,并为您的应用程序提供数据保护。

Before we begin and see how soft delete feature actually works, let’s run through the preliminaries that are required to perform our demonstration.

我们开始看到删除功能实际上是如何工作的软之前,让我们通过需要执行我们的演示预赛的运行。

先决条件 (Pre-requisites )

I am assuming you are already familiar with the Azure Portal and to get started, you need to have –

我假设您已经熟悉Azure门户,并且要开始使用,您需要-

In case, you are new to the Azure Storage account, I would recommend you to quickly go over these sites, Microsoft Azure documentation and Different Azure Storage types (File, Blob, Queue and Table) to learn how to create an Azure Storage account. The latter article also sheds light on different types of Storage available in Azure.

如果您是Azure存储帐户的新手,我建议您快速浏览这些站点, Microsoft Azure文档其他Azure存储类型(文件,Blob,队列和表),以了解如何创建Azure存储帐户。 后一篇文章还阐明了Azure中可用的不同类型的存储。

演示前的准备 (Preparations before demo)

For this demo, I have created an Azure Storage Account – azsqlshackstorage in the Resource Group azsqlshackrg with Pay-As-You-Go subscription. You can see these details along with different types of storages (Containers, File shares, Tables, Queues) in the screenshot below.

对于此演示,我在资源组 azsqlshackrg中创建了一个Azure存储帐户 – azsqlshackstorage,并带有即付即用订阅。 您可以在下面的屏幕快照中看到这些详细信息以及不同类型的存储(容器,文件共享,表,队列)。

Azure Storage Account details

Let’s move forward with Azure Blob Storage and for that click on Containers. Containers consist of a set of blobs in which data is stored. You will be taken to the following window.

让我们继续使用Azure Blob存储,然后单击Containers 。 容器由存储数据的一组Blob组成。 您将被带到以下窗口。

  • Click on + Container to add a new container

    单击+容器添加一个新的容器
  • Type a relevant name for your container, this name should be lowercase

    输入与您的容器相关的名称,该名称应为小写
  • You can restrict the access to your container, by default, it is Private (no anonymous access)

    您可以限制对容器的访问,默认情况下,它是私有的(无匿名访问)
  • Hit OK to create a container

    点击确定创建一个容器

Creating a container in Azure Storage account.

Let’s upload a few blobs in this newly created container in our Azure storage account. This is a straight forward process, just click on Upload and browse your file and hit the Upload button. If you see the below screenshot, you will find several files that are uploaded into sqlshackfinance container marked in a red ellipse.

让我们在Azure存储帐户的这个新创建的容器中上传一些Blob。 这是一个简单的过程,只需单击“上传”并浏览文件,然后单击“上传”按钮。 如果您看到以下屏幕截图,则会找到几个上传到sqlshackfinance 容器中并标有红色椭圆的文件。

Several files uploaded in Azure Blob Storage.

You can create as many containers and upload as many blobs (be it block blob, page blob or append blob) in your Azure Blob Storage. Of course, there is a limit on the maximum size of the blob that can be uploaded. You can read more about it here.

您可以在Azure Blob存储中创建尽可能多的容器并上传尽可能多的Blob(阻止Blob,页面Blob或追加Blob)。 当然,可以上传的Blob的最大大小是有限制的。 您可以在此处了解更多信息。

In nutshell, our setup looks like the below, where several blobs are grouped into the container, sqlshackfinances which in turn is tied to the Azure Storage account, azsqlshackstorage.

简而言之,我们的设置如下所示,其中几个blob分组到了sqlshackfinances容器中,而sqlshackfinances又与Azure存储帐户azsqlshackstorage绑定在一起。

Pictorial representation of Azure Blob Storage.

入门 (Getting started)

Now that the base set-up is ready, let’s proceed to see how we can enable soft delete in Azure Blob Storage to recover accidentally deleted files and prevent inadvertent data loss.

现在,基本设置已准备就绪,让我们继续看看如何在Azure Blob存储中启用软删除,以恢复意外删除的文件并防止意外数据丢失。

如何在Azure Blob存储中启用软删除? (How do I enable soft delete in Azure Blob Storage?)

Navigate to your storage account, and click Data Protection under Blob service. By default, this feature is disabled, select Enabled and also enter the number of days you want to retain your soft deleted data. Don’t forget to hit the Save button to save these changes.

导航到您的存储帐户,然后单击Blob服务下的“ 数据 保护 ”。 默认情况下,此功能为禁用状态,选择“ 启用”,然后输入要保留软删除数据的天数。 不要忘记点击“ 保存”按钮以保存这些更改。

“Successfully updated data protection settings for azsqlshackstorage” message will appear to ensure a soft delete feature is enabled.”

将显示“成功更新了azsqlshackstorage的数据保护设置”消息,以确保启用了软删除功能。”

Enable soft delete feature in blob storage.

To experience how soft delete feature works, we will delete a couple of files in the container. For this, go to your container, select files and click Delete.

为了体验软删除功能的工作原理,我们将删除容器中的几个文件。 为此,请转到您的容器 ,选择文件,然后单击“ 删除”

Deleting files in a container.

You will see the below pop up on clicking the Delete button. Since we haven’t taken any snapshots, so just click OK. We will talk about blob snapshots soon in this article.

单击删除按钮,您将看到以下弹出窗口。 由于我们尚未拍摄任何快照,因此只需单击确定 。 我们将在本文中很快讨论blob快照。

Delete blob(s) popup.

Two selected files are deleted from the container. Refer to the below screenshot.

从容器中删除了两个选定的文件。 请参考下面的屏幕截图。

Blobs are deleted from a container.

Click on Show deleted blobs button to see the list of deleted blobs as shown below.

单击“ 显示已删除的Blob”按钮以查看已删除的Blob的列表,如下所示。

Viewing the deleted blobs.

恢复已删除的Blob (Recovering deleted blobs)

Click on the ellipsis of the deleted blob and select Undelete from the contextual menu to recover this deleted blob. You cannot read soft-deleted blobs unless you undelete them first.

单击已删除的Blob的省略号,然后从上下文菜单中选择“ 取消删除 ”以恢复此已删除的Blob。 除非先取消删除软删除的Blob,否则无法读取它们。

Recovering deleted blobs.

On clicking Undelete above, the deleted blob is recovered and restored to its previous Active status as shown below.

单击上方的“取消删除”后,将删除已删除的Blob,并将其恢复为之前的“ 活动”状态,如下所示。

The deleted blob is recovered.

Before undeleting the blob, you can also select the soft-deleted blob to view its properties. It shows the date and time when the blob was deleted and also the number of days left until the blob is permanently deleted which is a very useful information for the users.

在取消删除Blob之前,您还可以选择已软删除的Blob以查看其属性。 它显示删除Blob的日期和时间,以及永久删除Blob之前剩余的天数,这对用户来说是非常有用的信息。

Properties of the soft deleted blob.

创建存储帐户时启用软删除 (Enable soft delete while creating a storage account)

Additionally, if you know beforehand that your project is going to deal with a large number of blobs with multiple users accessing it, it is always a good idea to ensure data protection and avoid erroneous data loss by enabling soft delete at the time of storage account creation. To do this, you will have to go to the Advanced tab, Data protection and select Enabled as shown below. You can also select the number of days you want to retain soft deleted data.

此外,如果您事先知道您的项目将要处理大量用户访问的大量Blob,那么在存储帐户时启用软删除功能来确保数据保护并避免错误数据丢失始终是一个好主意。创建。 为此,您必须转到高级选项卡,数据保护,然后选择启用,如下所示。 您还可以选择要保留软删除数据的天数。

Enabling soft delete feature while creating a storage account.

软删除是否也有助于恢复已删除的Blob快照? (Does soft delete help to recover deleted blob snapshots too?)

Absolutely. Blob snapshots are a read-only version of a blob and are usually used for backup or troubleshooting purposes. So say, we created a snapshot for Financing Agreement doc in the container, and mistakenly it got deleted. Soft delete offers similar support to recover these blob snapshots as well.

绝对。 Blob快照是Blob的只读版本,通常用于备份或故障排除。 可以这么说,我们在容器中为“融资协议”文档创建了快照,但错误地将其删除。 软删除也提供类似的支持来恢复这些Blob快照。

To see this in action, let’s quickly try to recover a snapshot, for that, right-click on the ellipsis on the extreme right side of Financing Agreement document and select Create snapshot. The message “Successfully created blob snapshot(s)” is quickly displayed. Make sure, soft delete feature is already enabled.

要查看实际情况,让我们快速尝试恢复快照,为此,右键单击Financing Agreement文档最右端的省略号,然后选择创建快照 。 Swift显示“成功创建Blob快照”消息。 确保软删除功能已启用。

Creating blob snapshots

Now go to the blob, click on Snapshots in the menu tab, select the snapshot and finally hit Delete snapshot button.

现在转到Blob,在菜单选项卡中单击快照,选择快照,最后单击删除快照按钮。

Deleting a snapshot.

The above action will delete the snapshot as shown in the screenshot below.

上面的操作将删除快照,如下面的屏幕快照所示。

Snapshot deleted.
You can see the list of deleted snapshots by selecting the checkbox “Show deleted snapshots” as you would for blobs.

您可以通过选中“显示已删除的快照”复选框来查看已删除快照的列表,就像处理blob一样。

Recovering the deleted blob snapshot.

Just a piece of quick advice here – Be extra careful when creating blob snapshots, as charges are incurred for the additional data storage.

这里只是个快速建议–创建Blob快照时要格外小心,因为额外的数据存储会产生费用。

Before I end this discussion, I think it is worth to discuss, what if the container or the storage account containing blobs is deleted? Will we be able to recover deleted files with soft delete feature being enabled in this case?

在结束讨论之前,我认为值得讨论,如果删除包含blob的容器或存储帐户该怎么办? 在这种情况下启用软删除功能后,我们是否能够恢复已删除的文件?

The answer is NO, since the storage account or container that contains blobs is deleted, everything is deleted permanently including soft-deleted blobs.

答案是否定的,因为删除了包含blob的存储帐户或容器,因此所有内容(包括软删除的blob)都会被永久删除。

To prevent accidental deletions of resources like storage account, containers, databases etc. in Azure, it is a good practice to make use of Locks. To understand how to put a lock on Azure resources, you can go over this article, here, Protecting Azure SQL databases from accidental deletion.

为防止意外删除Azure中的存储帐户,容器,数据库等资源 ,使用锁是一个好习惯。 要了解如何锁定Azure资源,可以阅读本文,这里是保护Azure SQL数据库免于意外删除

摘要 (Summary)

During the demo of this article, we discussed, how we can enable the soft delete feature in Azure Blob Storage to recover blob storage data that is erroneously deleted. This feature also helps to recover deleted blob snapshots. This adds one more layer to the data protection strategy and prevents inadvertent data loss.

在本文的演示期间,我们讨论了如何在Azure Blob存储中启用软删除功能以恢复错误删除的Blob存储数据。 此功能还有助于恢复已删除的Blob快照。 这为数据保护策略增加了一层,并防止了意外的数据丢失。

翻译自: https://www.sqlshack.com/how-to-recover-accidental-deletes-in-azure-blob-storage/

azure blob

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值