|
| 1 | +--- |
| 2 | +title: Enable and manage point-in-time restore for block blobs (preview) |
| 3 | +titleSuffix: Azure Storage |
| 4 | +description: Learn how to use point-in-time restore (preview) to restore block blobs to a state at an earlier point in time. |
| 5 | +services: storage |
| 6 | +author: tamram |
| 7 | + |
| 8 | +ms.service: storage |
| 9 | +ms.topic: how-to |
| 10 | +ms.date: 05/06/2020 |
| 11 | +ms.author: tamram |
| 12 | +ms.subservice: blobs |
| 13 | +--- |
| 14 | + |
| 15 | +# Enable and manage point-in-time restore for block blobs (preview) |
| 16 | + |
| 17 | +You can use point-in-time restore (preview) to restore block blobs to their state at an earlier point in time. This article describes how to enable point-in-time restore for a storage account with PowerShell. It also shows how to perform a restore operation with PowerShell. |
| 18 | + |
| 19 | +For more information and to learn how to register for the preview, see [Point-in-time restore for block blobs (preview)](point-in-time-restore-overview.md). |
| 20 | + |
| 21 | +> [!CAUTION] |
| 22 | +> Point-in-time restore supports restoring operations on block blobs only. Operations on containers cannot be restored. If you delete a container from the storage account by calling the [Delete Container](/rest/api/storageservices/delete-container) operation during the point-in-time restore preview, that container cannot be restored with a restore operation. During the preview, instead of deleting a container, delete individual blobs if you may want to restore them. |
| 23 | +
|
| 24 | +> [!IMPORTANT] |
| 25 | +> The point-in-time restore preview is intended for non-production use only. Production service-level agreements (SLAs) are not currently available. |
| 26 | +
|
| 27 | +## Install the preview module |
| 28 | + |
| 29 | +To configure Azure point-in-time restore with PowerShell, first install version [1.14.1-preview](https://www.powershellgallery.com/packages/Az.Storage/1.14.1-preview) of the Az.Storage PowerShell module. Follow these steps to install the preview module: |
| 30 | + |
| 31 | +1. Uninstall any previous installations of Azure PowerShell from Windows using the **Apps & features** setting under **Settings**. |
| 32 | + |
| 33 | +1. Make sure that you have the latest version of PowerShellGet installed. Open a Windows PowerShell window, and run the following command to install the latest version: |
| 34 | + |
| 35 | + ```powershell |
| 36 | + Install-Module PowerShellGet –Repository PSGallery –Force |
| 37 | + ``` |
| 38 | +
|
| 39 | +1. Close and reopen the PowerShell window after installing PowerShellGet. |
| 40 | +
|
| 41 | +1. Install the latest version of Azure PowerShell: |
| 42 | +
|
| 43 | + ```powershell |
| 44 | + Install-Module Az –Repository PSGallery –AllowClobber |
| 45 | + ``` |
| 46 | +
|
| 47 | +1. Install the Az.Storage preview module: |
| 48 | +
|
| 49 | + ```powershell |
| 50 | + Install-Module Az.Storage -Repository PSGallery -RequiredVersion 1.14.1-preview -AllowPrerelease -AllowClobber -Force |
| 51 | + ``` |
| 52 | +
|
| 53 | +For more information about installing Azure PowerShell, see [Install Azure PowerShell with PowerShellGet](/powershell/azure/install-az-ps). |
| 54 | +
|
| 55 | +## Enable and configure point-in-time restore |
| 56 | +
|
| 57 | +Before you enable and configure point-in-time restore, enable its prerequisites: soft delete, change feed, and blob versioning. For more information about enabling each of these features, see these articles: |
| 58 | +
|
| 59 | +- [Enable soft delete for blobs](soft-delete-enable.md) |
| 60 | +- [Enable and disable the change feed](storage-blob-change-feed.md#enable-and-disable-the-change-feed) |
| 61 | +- [Enable and manage blob versioning](versioning-enable.md) |
| 62 | +
|
| 63 | +To configure Azure point-in-time restore with PowerShell, call the Enable-AzStorageBlobRestorePolicy command. The following example enables soft delete and sets the soft-delete retention period, enables change feed, and then enables point-in-time restore. Before running the example, use the Azure portal or an Azure Resource Manager template to also enable blob versioning. |
| 64 | +
|
| 65 | +When running the example, remember to replace the values in angle brackets with your own values: |
| 66 | +
|
| 67 | +```powershell |
| 68 | +# Sign in to your Azure account. |
| 69 | +Connect-AzAccount |
| 70 | +
|
| 71 | +# Set resource group and account variables. |
| 72 | +$rgName = "<resource-group>" |
| 73 | +$accountName = "<storage-account>" |
| 74 | +
|
| 75 | +# Enable soft delete with a retention of 6 days. |
| 76 | +Enable-AzStorageBlobDeleteRetentionPolicy -ResourceGroupName $rgName ` |
| 77 | + -StorageAccountName $accountName ` |
| 78 | + -RetentionDays 6 |
| 79 | +
|
| 80 | +# Enable change feed. |
| 81 | +Update-AzStorageBlobServiceProperty -ResourceGroupName $rgName ` |
| 82 | + -StorageAccountName $accountName ` |
| 83 | + -EnableChangeFeed $true |
| 84 | +
|
| 85 | +# Enable point-in-time restore with a retention period of 5 days. |
| 86 | +# The retention period for point-in-time restore must be at least one day less than that set for soft delete. |
| 87 | +Enable-AzStorageBlobRestorePolicy -ResourceGroupName $rgName ` |
| 88 | + -StorageAccountName $accountName ` |
| 89 | + -RestoreDays 5 |
| 90 | +
|
| 91 | +# View the service settings. |
| 92 | +Get-AzStorageBlobServiceProperty -ResourceGroupName $rgName ` |
| 93 | + -StorageAccountName $accountName |
| 94 | +``` |
| 95 | + |
| 96 | +## Perform a restore operation |
| 97 | + |
| 98 | +To initiate a restore operation, call the Restore-AzStorageBlobRange command, specifying the restore point as a UTC **DateTime** value. You can specify one or more lexicographical ranges of blobs to restore, or omit a range to restore all blobs in all containers in the storage account. The restore operation may take several minutes to complete. |
| 99 | + |
| 100 | +Keep in mind the following rules when specifying a range of blobs to restore: |
| 101 | + |
| 102 | +- The container pattern specified for the start range and end range must include a minimum of three characters. The forward slash (/) that is used to separate a container name from a blob name does not count toward this minimum. |
| 103 | +- Only one range can be specified per restore operation. |
| 104 | +- Wildcard characters are not supported. They are treated as standard characters. |
| 105 | +- You can restore blobs in the `$root` and `$web` containers by explicitly specifying them in a range passed to a restore operation. The `$root` and `$web` containers are restored only if they are explicitly specified. Other system containers cannot restored. |
| 106 | + |
| 107 | +### Restore all containers in the account |
| 108 | + |
| 109 | +To restore all containers and blobs in the storage account, call the Restore-AzStorageBlobRange command, omitting the `-BlobRestoreRange` parameter. The following example restores containers in the storage account to their state 12 hours before the present moment: |
| 110 | + |
| 111 | +```powershell |
| 112 | +# Specify -TimeToRestore as a UTC value |
| 113 | +Restore-AzStorageBlobRange -ResourceGroupName $rgName ` |
| 114 | + -StorageAccountName $accountName ` |
| 115 | + -TimeToRestore (Get-Date).AddHours(-12) |
| 116 | +``` |
| 117 | + |
| 118 | +### Restore a single range of block blobs |
| 119 | + |
| 120 | +To restore a range of blobs, call the Restore-AzStorageBlobRange command and specify a lexicographical range of container and blob names for the `-BlobRestoreRange` parameter. The start of the range is in inclusive, and the end of the range is exclusive. |
| 121 | + |
| 122 | +For example, to restore the blobs in a single container named *sample-container*, you can specify a range that starts with *sample-container* and ends with *sample-container1*. There is no requirement for the containers named in the start and end ranges to exist. Because the end of the range is exclusive, even if the storage account includes a container named *sample-container1*, only the container named *sample-container* will be restored: |
| 123 | + |
| 124 | +```powershell |
| 125 | +$range = New-AzStorageBlobRangeToRestore -StartRange sample-container -EndRange sample-container1 |
| 126 | +``` |
| 127 | + |
| 128 | +To specify a subset of blobs in a container to restore, use a forward slash (/) to separate the container name from the blob pattern. For example, the following range selects blobs in a single container whose names begin with the letters *d* through *f*: |
| 129 | + |
| 130 | +```powershell |
| 131 | +$range = New-AzStorageBlobRangeToRestore -StartRange sample-container/d -EndRange sample-container/g |
| 132 | +``` |
| 133 | + |
| 134 | +Next, provide the range to the Restore-AzStorageBlobRange command. Specify the restore point by providing a UTC **DateTime** value for the `-TimeToRestore` parameter. The following example restores blobs in the specified range to their state 3 days before the present moment: |
| 135 | + |
| 136 | +```powershell |
| 137 | +# Specify -TimeToRestore as a UTC value |
| 138 | +Restore-AzStorageBlobRange -ResourceGroupName $rgName ` |
| 139 | + -StorageAccountName $accountName ` |
| 140 | + -BlobRestoreRange $range ` |
| 141 | + -TimeToRestore (Get-Date).AddDays(-3) |
| 142 | +``` |
| 143 | + |
| 144 | +### Restore multiple ranges of block blobs |
| 145 | + |
| 146 | +To restore multiple ranges of block blobs, specify an array of ranges for the `-BlobRestoreRange` parameter. The following example restores the complete contents of *container1* and *container4*: |
| 147 | + |
| 148 | +```powershell |
| 149 | +$range1 = New-AzStorageBlobRangeToRestore -StartRange container1 -EndRange container2 |
| 150 | +$range2 = New-AzStorageBlobRangeToRestore -StartRange container4 -EndRange container5 |
| 151 | +
|
| 152 | +Restore-AzStorageBlobRange -ResourceGroupName $rgName ` |
| 153 | + -StorageAccountName $accountName ` |
| 154 | + -TimeToRestore (Get-Date).AddMinutes(-30) ` |
| 155 | + -BlobRestoreRange @($range1, $range2) |
| 156 | +``` |
| 157 | + |
| 158 | +## Next steps |
| 159 | + |
| 160 | +- [Point-in-time restore for block blobs (preview)](point-in-time-restore-overview.md) |
| 161 | +- [Soft delete](soft-delete-overview.md) |
| 162 | +- [Change feed (preview)](storage-blob-change-feed.md) |
| 163 | +- [Blob versioning (preview)](versioning-overview.md) |
0 commit comments