|
| 1 | +--- |
| 2 | +title: Enable soft delete - Azure file shares |
| 3 | +description: Learn how to enable soft delete on Azure file shares for data recovery and preventing accidental deletion. |
| 4 | +author: roygara |
| 5 | +ms.service: storage |
| 6 | +ms.topic: conceptual |
| 7 | +ms.date: 05/22/2020 |
| 8 | +ms.author: rogarana |
| 9 | +ms.subservice: files |
| 10 | +services: storage |
| 11 | +--- |
| 12 | + |
| 13 | +# Enable soft delete on Azure file shares |
| 14 | + |
| 15 | +Azure Storage offers soft delete for file shares so that you can more easily recover your data when it is mistakenly deleted by an application or other storage account user. To learn more about soft delete, see [How to prevent accidental deletion of Azure file shares](storage-files-prevent-file-share-deletion.md). |
| 16 | + |
| 17 | +The following sections show how to enable and use soft delete for Azure file shares on an existing storage account: |
| 18 | + |
| 19 | +# [Portal](#tab/azure-portal) |
| 20 | + |
| 21 | +1. Sign into the [Azure portal](https://portal.azure.com/). |
| 22 | +1. Navigate to your storage account and select **Soft delete** under **File service**. |
| 23 | +1. Select **Enabled** for **file share soft delete**. |
| 24 | +1. Select **File share retention period in days** and enter a number of your choosing. |
| 25 | +1. Select **Save** to confirm your data retention settings. |
| 26 | + |
| 27 | +:::image type="content" source="media/storage-how-to-recover-deleted-account/enable-soft-delete-files.png" alt-text="Screenshot of the storage account soft delete settings pane. Highlighting the file shares section, enable toggle, set a retention period, and save. This will enable soft delete for all file shares in your storage account."::: |
| 28 | + |
| 29 | +# [PowerShell](#tab/azure-powershell) |
| 30 | + |
| 31 | +To enable soft delete, you must update a file client's service properties. The following example enables soft delete for all file shares in a storage account: |
| 32 | + |
| 33 | +```azurepowershell-interactive |
| 34 | +$rgName = "yourResourceGroupName" |
| 35 | +$accountName = "yourStorageAccountName" |
| 36 | +
|
| 37 | +Update-AzStorageFileServiceProperty -ResourceGroupName $rgName -StorageAccountName $accountName -EnableShareDeleteRetentionPolicy $true -ShareRetentionDays 7 |
| 38 | +``` |
| 39 | + |
| 40 | +You can verify if soft delete is enabled and view its retention policy with the following command: |
| 41 | + |
| 42 | +```azurepowershell-interactive |
| 43 | +Get-AzStorageFileServiceProperty -ResourceGroupName $rgName -StorageAccountName $accountName |
| 44 | +``` |
| 45 | +--- |
| 46 | + |
| 47 | +## Restore soft deleted file share |
| 48 | + |
| 49 | +# [Portal](#tab/azure-portal) |
| 50 | + |
| 51 | +To restore a soft deleted file share: |
| 52 | + |
| 53 | +1. Navigate to your storage account and select **File shares**. |
| 54 | +1. On the file share blade, enable **Show deleted shares** to display any shares that have been soft deleted. |
| 55 | + |
| 56 | + This will display any shares currently in a **Deleted** state. |
| 57 | + |
| 58 | + :::image type="content" source="media/storage-how-to-recover-deleted-account/undelete-file-share.png" alt-text="If the status column, the column next to the name column, is set to deleted, then your file share is in a soft deleted state. And will be permanently deleted after your specified retention period."::: |
| 59 | + |
| 60 | +1. Select the share and select **undelete**, this will restore the share. |
| 61 | + |
| 62 | + You can confirm the share is restored since its status switches to **Active**. |
| 63 | + |
| 64 | + :::image type="content" source="media/storage-how-to-recover-deleted-account/restored-file-share.png" alt-text="If the status column, the column next to the name column, is set to Active, then your file share has been restored."::: |
| 65 | + |
| 66 | +# [PowerShell](#tab/azure-powershell) |
| 67 | + |
| 68 | +To restore a soft deleted file share, use the following command: |
| 69 | + |
| 70 | +```azurepowershell-interactive |
| 71 | +Restore-AzRmStorageShare -ResourceGroupName $rgname -StorageAccountName $accountName -DeletedShareVersion 01D5E2783BDCDA97 |
| 72 | +``` |
| 73 | +--- |
| 74 | + |
| 75 | +## Disable soft delete |
| 76 | + |
| 77 | +If you wish to stop using soft delete, or permanently delete a file share, follow these instructions: |
| 78 | + |
| 79 | +# [Portal](#tab/azure-portal) |
| 80 | + |
| 81 | +1. Navigate to your storage account and select **Soft delete** under **Settings**. |
| 82 | +1. Under **File shares** select **Disabled** for **Soft delete for file shares**. |
| 83 | +1. Select **Save** to confirm your data retention settings. |
| 84 | + |
| 85 | + :::image type="content" source="media/storage-how-to-recover-deleted-account/disable-soft-delete-files.png" alt-text="Disabling soft delete will allow you to immediately and permanently delete all file shares in your storage account at your leisure."::: |
| 86 | + |
| 87 | +# [PowerShell](#tab/azure-powershell) |
| 88 | + |
| 89 | +You can use the following command to disable soft delete on your storage account: |
| 90 | + |
| 91 | +```azurepowershell-interactive |
| 92 | +Update-AzStorageFileServiceProperty -ResourceGroupName $rgName -StorageAccountName $accountName -EnableShareDeleteRetentionPolicy $false |
| 93 | +``` |
| 94 | +--- |
0 commit comments