Skip to content

Commit 44c87c0

Browse files
Merge pull request #110303 from dcurwin/april5-2020
AFS multiple file restore
2 parents 849684e + 375541e commit 44c87c0

File tree

1 file changed

+57
-4
lines changed

1 file changed

+57
-4
lines changed

articles/backup/restore-afs-powershell.md

Lines changed: 57 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,15 @@ ms.date: 1/27/2020
77

88
# Restore Azure Files with PowerShell
99

10-
This article explains how to restore an entire file share, or specific files, from a restore point created by the [Azure Backup](backup-overview.md) service using Azure Powershell.
10+
This article explains how to restore an entire file share, or specific files, from a restore point created by the [Azure Backup](backup-overview.md) service using Azure PowerShell.
1111

1212
You can restore an entire file share or specific files on the share. You can restore to the original location, or to an alternate location.
1313

1414
> [!WARNING]
15-
> Make sure the PS version is upgraded to the minimum version for 'Az.RecoveryServices 2.6.0' for AFS backups. For more details, refer to [the section](backup-azure-afs-automation.md#important-notice---backup-item-identification-for-afs-backups) outlining the requirement for this change.
15+
> Make sure the PS version is upgraded to the minimum version for 'Az.RecoveryServices 2.6.0' for AFS backups. For more information, see [the section](backup-azure-afs-automation.md#important-notice---backup-item-identification-for-afs-backups) outlining the requirement for this change.
16+
17+
>[!NOTE]
18+
>Azure Backup now supports restoring multiple files or folders to the original or alternate Location using PowerShell. Refer to [this section](#restore-multiple-files-or-folders-to-original-or-alternate-location) the document to learn how.
1619
1720
## Fetch recovery points
1821

@@ -97,18 +100,68 @@ This command returns a job with an ID to be tracked, as shown in the previous se
97100

98101
When you restore to an original location, you don't need to specify destination- and target-related parameters. Only **ResolveConflict** must be provided.
99102

100-
#### Overwrite an Azure file share
103+
### Overwrite an Azure file share
101104

102105
```powershell
103106
Restore-AzRecoveryServicesBackupItem -RecoveryPoint $rp[0] -ResolveConflict Overwrite
104107
```
105108

106-
#### Overwrite an Azure file
109+
### Overwrite an Azure file
107110

108111
```powershell
109112
Restore-AzRecoveryServicesBackupItem -RecoveryPoint $rp[0] -SourceFileType File -SourceFilePath "TestDir/TestDoc.docx" -ResolveConflict Overwrite
110113
```
111114

115+
## Restore multiple files or folders to original or alternate location
116+
117+
Use the [Restore-AzRecoveryServicesBackupItem](https://docs.microsoft.com/powershell/module/az.recoveryservices/restore-azrecoveryservicesbackupitem?view=azps-1.4.0) command by passing the path of all files or folders you want to restore as a value for the **MultipleSourceFilePath** parameter.
118+
119+
### Restore multiple files
120+
121+
In the following script, we're trying to restore the *FileSharePage.png* and *MyTestFile.txt* files.
122+
123+
```powershell
124+
$vault = Get-AzRecoveryServicesVault -ResourceGroupName "azurefiles" -Name "azurefilesvault"
125+
126+
$Container = Get-AzRecoveryServicesBackupContainer -ContainerType AzureStorage -Status Registered -FriendlyName "afsaccount" -VaultId $vault.ID
127+
128+
$BackupItem = Get-AzRecoveryServicesBackupItem -Container $Container -WorkloadType AzureFiles -VaultId $vault.ID -FriendlyName "azurefiles"
129+
130+
$RP = Get-AzRecoveryServicesBackupRecoveryPoint -Item $BackupItem -VaultId $vault.ID
131+
132+
$files = ("FileSharePage.png", "MyTestFile.txt")
133+
134+
Restore-AzRecoveryServicesBackupItem -RecoveryPoint $RP[0] -MultipleSourceFilePath $files -SourceFileType File -ResolveConflict Overwrite -VaultId $vault.ID -VaultLocation $vault.Location
135+
```
136+
137+
### Restore multiple directories
138+
139+
In the following script, we're trying to restore the *zrs1_restore* and *Restore* directories.
140+
141+
```powershell
142+
$vault = Get-AzRecoveryServicesVault -ResourceGroupName "azurefiles" -Name "azurefilesvault"
143+
144+
$Container = Get-AzRecoveryServicesBackupContainer -ContainerType AzureStorage -Status Registered -FriendlyName "afsaccount" -VaultId $vault.ID
145+
146+
$BackupItem = Get-AzRecoveryServicesBackupItem -Container $Container -WorkloadType AzureFiles -VaultId $vault.ID -FriendlyName "azurefiles"
147+
148+
$RP = Get-AzRecoveryServicesBackupRecoveryPoint -Item $BackupItem -VaultId $vault.ID
149+
150+
$files = ("Restore","zrs1_restore")
151+
152+
Restore-AzRecoveryServicesBackupItem -RecoveryPoint $RP[0] -MultipleSourceFilePath $files -SourceFileType Directory -ResolveConflict Overwrite -VaultId $vault.ID -VaultLocation $vault.Location
153+
```
154+
155+
The output will be similar to the following:
156+
157+
```output
158+
WorkloadName Operation Status StartTime EndTime JobID
159+
------------ --------- ------ --------- ------- -----
160+
azurefiles Restore InProgress 4/5/2020 8:01:24 AM cd36abc3-0242-44b1-9964-0a9102b74d57
161+
```
162+
163+
If you want to restore multiple files or folders to alternate location, use the scripts above by specifying the target location-related parameter values, as explained above in [Restore an Azure file to an alternate location](#restore-an-azure-file-to-an-alternate-location).
164+
112165
## Next steps
113166

114167
[Learn about](restore-afs.md) restoring Azure Files in the Azure portal.

0 commit comments

Comments
 (0)