Skip to content

Commit f42deea

Browse files
author
David Curwin
committed
added articles for restore and manage
1 parent ab6b0df commit f42deea

File tree

4 files changed

+225
-184
lines changed

4 files changed

+225
-184
lines changed

articles/backup/backup-azure-afs-automation.md

Lines changed: 4 additions & 184 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
---
2-
title: Back up and restore Azure Files with PowerShell
3-
description: In this article, learn how to back up and restore Azure Files using the Azure Backup service and PowerShell.
2+
title: Back up Azure Files with PowerShell
3+
description: In this article, learn how to back up Azure Files using the Azure Backup service and PowerShell.
44
ms.topic: conceptual
55
ms.date: 08/20/2019
66
---
77

8-
# Back up and restore Azure Files with PowerShell
8+
# Back up Azure Files with PowerShell
99

10-
This article describes how to use Azure PowerShell to back up and recover an Azure Files file share using an [Azure Backup](backup-overview.md) Recovery Services vault.
10+
This article describes how to use Azure PowerShell to back up an Azure Files file share using an [Azure Backup](backup-overview.md) Recovery Services vault.
1111

1212
This article explains how to:
1313

@@ -17,8 +17,6 @@ This article explains how to:
1717
> * Create a Recovery Services vault.
1818
> * Configure backup for an Azure file share.
1919
> * Run a backup job.
20-
> * Restore a backed up Azure file share, or an individual file from a share.
21-
> * Monitor backup and restore jobs.
2220
2321
## Before you start
2422

@@ -283,184 +281,6 @@ $afsBkpItem = Get-AzRecoveryServicesBackupItem -Container $afsContainer -Workloa
283281
Enable-AzRecoveryServicesBackupProtection -Item $afsBkpItem -Policy $monthlyafsPol
284282
```
285283

286-
## Restore Azure file shares and files
287-
288-
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.
289-
290-
### Fetch recovery points
291-
292-
Use [Get-AzRecoveryServicesBackupRecoveryPoint](https://docs.microsoft.com/powershell/module/az.recoveryservices/get-azrecoveryservicesbackuprecoverypoint?view=azps-1.4.0) to list all recovery points for the backed-up item.
293-
294-
In the following script:
295-
296-
* The variable **$rp** is an array of recovery points for the selected backup item from the past seven days.
297-
* The array is sorted in reverse order of time with the latest recovery point at index **0**.
298-
* Use standard PowerShell array indexing to pick the recovery point.
299-
* In the example, **$rp[0]** selects the latest recovery point.
300-
301-
```powershell
302-
$startDate = (Get-Date).AddDays(-7)
303-
$endDate = Get-Date
304-
$rp = Get-AzRecoveryServicesBackupRecoveryPoint -Item $afsBkpItem -StartDate $startdate.ToUniversalTime() -EndDate $enddate.ToUniversalTime()
305-
306-
$rp[0] | fl
307-
```
308-
309-
The output is similar to the following.
310-
311-
```powershell
312-
FileShareSnapshotUri : https://testStorageAcct.file.core.windows.net/testAzureFS?sharesnapshot=2018-11-20T00:31:04.00000
313-
00Z
314-
RecoveryPointType : FileSystemConsistent
315-
RecoveryPointTime : 11/20/2018 12:31:05 AM
316-
RecoveryPointId : 86593702401459
317-
ItemName : testAzureFS
318-
Id : /Subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testVaultRG/providers/Micros oft.RecoveryServices/vaults/testVault/backupFabrics/Azure/protectionContainers/StorageContainer;storage;teststorageRG;testStorageAcct/protectedItems/AzureFileShare;testAzureFS/recoveryPoints/86593702401462
319-
WorkloadType : AzureFiles
320-
ContainerName : storage;teststorageRG;testStorageAcct
321-
ContainerType : AzureStorage
322-
BackupManagementType : AzureStorage
323-
```
324-
325-
After the relevant recovery point is selected, you restore the file share or file to the original location, or to an alternate location.
326-
327-
### Restore an Azure file share to an alternate location
328-
329-
Use the [Restore-AzRecoveryServicesBackupItem](https://docs.microsoft.com/powershell/module/az.recoveryservices/restore-azrecoveryservicesbackupitem?view=azps-1.4.0) to restore to the selected recovery point. Specify these parameters to identify the alternate location:
330-
331-
* **TargetStorageAccountName**: The storage account to which the backed-up content is restored. The target storage account must be in the same location as the vault.
332-
* **TargetFileShareName**: The file shares within the target storage account to which the backed-up content is restored.
333-
* **TargetFolder**: The folder under the file share to which data is restored. If the backed-up content is to be restored to a root folder, give the target folder values as an empty string.
334-
* **ResolveConflict**: Instruction if there's a conflict with the restored data. Accepts **Overwrite** or **Skip**.
335-
336-
Run the cmdlet with the parameters as follows:
337-
338-
```powershell
339-
Restore-AzRecoveryServicesBackupItem -RecoveryPoint $rp[0] -TargetStorageAccountName "TargetStorageAcct" -TargetFileShareName "DestAFS" -TargetFolder "testAzureFS_restored" -ResolveConflict Overwrite
340-
```
341-
342-
The command returns a job with an ID to be tracked, as shown in the following example.
343-
344-
```powershell
345-
WorkloadName Operation Status StartTime EndTime JobID
346-
------------ --------- ------ --------- ------- -----
347-
testAzureFS Restore InProgress 12/10/2018 9:56:38 AM 9fd34525-6c46-496e-980a-3740ccb2ad75
348-
```
349-
350-
### Restore an Azure file to an alternate location
351-
352-
Use the [Restore-AzRecoveryServicesBackupItem](https://docs.microsoft.com/powershell/module/az.recoveryservices/restore-azrecoveryservicesbackupitem?view=azps-1.4.0) to restore to the selected recovery point. Specify these parameters to identify the alternate location, and to uniquely identify the file you want to restore.
353-
354-
* **TargetStorageAccountName**: The storage account to which the backed-up content is restored. The target storage account must be in the same location as the vault.
355-
* **TargetFileShareName**: The file shares within the target storage account to which the backed-up content is restored.
356-
* **TargetFolder**: The folder under the file share to which data is restored. If the backed-up content is to be restored to a root folder, give the target folder values as an empty string.
357-
* **SourceFilePath**: The absolute path of the file, to be restored within the file share, as a string. This path is the same path used in the **Get-AzStorageFile** PowerShell cmdlet.
358-
* **SourceFileType**: Whether a directory or a file is selected. Accepts **Directory** or **File**.
359-
* **ResolveConflict**: Instruction if there's a conflict with the restored data. Accepts **Overwrite** or **Skip**.
360-
361-
The additional parameters (SourceFilePath and SourceFileType) are related only to the individual file you want to restore.
362-
363-
```powershell
364-
Restore-AzRecoveryServicesBackupItem -RecoveryPoint $rp[0] -TargetStorageAccountName "TargetStorageAcct" -TargetFileShareName "DestAFS" -TargetFolder "testAzureFS_restored" -SourceFileType File -SourceFilePath "TestDir/TestDoc.docx" -ResolveConflict Overwrite
365-
```
366-
367-
This command returns a job with an ID to be tracked, as shown in the previous section.
368-
369-
### Restore Azure file shares and files to the original location
370-
371-
When you restore to an original location, you don't need to specify destination- and target-related parameters. Only **ResolveConflict** must be provided.
372-
373-
#### Overwrite an Azure file share
374-
375-
```powershell
376-
Restore-AzRecoveryServicesBackupItem -RecoveryPoint $rp[0] -ResolveConflict Overwrite
377-
```
378-
379-
#### Overwrite an Azure file
380-
381-
```powershell
382-
Restore-AzRecoveryServicesBackupItem -RecoveryPoint $rp[0] -SourceFileType File -SourceFilePath "TestDir/TestDoc.docx" -ResolveConflict Overwrite
383-
```
384-
385-
## Track backup and restore jobs
386-
387-
On-demand backup and restore operations return a job along with an ID, as shown when you [ran an on-demand backup](#trigger-an-on-demand-backup). Use the [Get-AzRecoveryServicesBackupJobDetails](https://docs.microsoft.com/powershell/module/az.recoveryservices/get-azrecoveryservicesbackupjob?view=azps-1.4.0) cmdlet to track the job progress and details.
388-
389-
```powershell
390-
$job = Get-AzRecoveryServicesBackupJob -JobId 00000000-6c46-496e-980a-3740ccb2ad75 -VaultId $vaultID
391-
392-
$job | fl
393-
394-
395-
IsCancellable : False
396-
IsRetriable : False
397-
ErrorDetails : {Microsoft.Azure.Commands.RecoveryServices.Backup.Cmdlets.Models.AzureFileShareJobErrorInfo}
398-
ActivityId : 00000000-5b71-4d73-9465-8a4a91f13a36
399-
JobId : 00000000-6c46-496e-980a-3740ccb2ad75
400-
Operation : Restore
401-
Status : Failed
402-
WorkloadName : testAFS
403-
StartTime : 12/10/2018 9:56:38 AM
404-
EndTime : 12/10/2018 11:03:03 AM
405-
Duration : 01:06:24.4660027
406-
BackupManagementType : AzureStorage
407-
408-
$job.ErrorDetails
409-
410-
ErrorCode ErrorMessage Recommendations
411-
--------- ------------ ---------------
412-
1073871825 Microsoft Azure Backup encountered an internal error. Wait for a few minutes and then try the operation again. If the issue persists, please contact Microsoft support.
413-
```
414-
415-
## Manage Azure File Shares backup
416-
417-
### Stop Protection on a file share
418-
419-
There are two ways to stop protecting Azure file shares:
420-
421-
* Stop all future backup jobs and *delete* all recovery points
422-
* Stop all future backup jobs but *leave* the recovery points
423-
424-
There may be a cost associated with leaving the recovery points in storage, as the underlying snapshots created by Azure Backup will be retained. However, the benefit of leaving the recovery points is you can restore the file share later, if desired. For information about the cost of leaving the recovery points, see the [pricing details](https://azure.microsoft.com/pricing/details/storage/files/). If you choose to delete all recovery points, you can't restore the file share.
425-
426-
#### Stop Protection and retain recovery points
427-
428-
To stop protection while retaining data, use the [Disable-AzRecoveryServicesBackupProtection](https://docs.microsoft.com/powershell/module/az.recoveryservices/disable-azrecoveryservicesbackupprotection?view=azps-3.3.0) cmdlet.
429-
430-
The following example stops protection for the *afsfileshare* file share but retains all recovery points:
431-
432-
```powershell
433-
$vaultID = Get-AzRecoveryServicesVault -ResourceGroupName "afstesting" -Name "afstest" | select -ExpandProperty ID
434-
$bkpItem = Get-AzRecoveryServicesBackupItem -BackupManagementType AzureStorage -WorkloadType AzureFiles -Name "afsfileshare" -VaultId $vaultID
435-
Disable-AzRecoveryServicesBackupProtection -Item $bkpItem -VaultId $vaultID
436-
```
437-
438-
```output
439-
WorkloadName Operation Status StartTime EndTime JobID
440-
------------ --------- ------ --------- ------- -----
441-
afsfileshare DisableBackup Completed 1/26/2020 2:43:59 PM 1/26/2020 2:44:21 PM 98d9f8a1-54f2-4d85-8433-c32eafbd793f
442-
```
443-
444-
The Job ID attribute in the output corresponds to the Job ID of the job that is created by the backup service for your “stop protection” operation. To track the status of the job, use the [Get-AzRecoveryServicesBackupJob](https://docs.microsoft.com/powershell/module/az.recoveryservices/get-azrecoveryservicesbackupjob?view=azps-3.3.0) cmdlet.
445-
446-
#### Stop Protection without retaining recovery points
447-
448-
To stop protection without retaining recovery points, use the [Disable-AzRecoveryServicesBackupProtection](https://docs.microsoft.com/powershell/module/az.recoveryservices/disable-azrecoveryservicesbackupprotection?view=azps-3.3.0) cmdlet and add the **-RemoveRecoveryPoints** parameter.
449-
450-
The following example stops protection for the *afsfileshare* file share without retaining recovery points:
451-
452-
```powershell
453-
$vaultID = Get-AzRecoveryServicesVault -ResourceGroupName "afstesting" -Name "afstest" | select -ExpandProperty ID
454-
$bkpItem = Get-AzRecoveryServicesBackupItem -BackupManagementType AzureStorage -WorkloadType AzureFiles -Name "afsfileshare" -VaultId $vaultID
455-
Disable-AzRecoveryServicesBackupProtection -Item $bkpItem -VaultId $vaultID -RemoveRecoveryPoints
456-
```
457-
458-
```output
459-
WorkloadName Operation Status StartTime EndTime JobID
460-
------------ --------- ------ --------- ------- -----
461-
afsfileshare DeleteBackupData Completed 1/26/2020 2:50:57 PM 1/26/2020 2:51:39 PM b1a61c0b-548a-4687-9d15-9db1cc5bcc85
462-
```
463-
464284
## Next steps
465285

466286
[Learn about](backup-afs.md) backing up Azure Files in the Azure portal.
Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
---
2+
title: Manage Azure file share backups with PowerShell
3+
description: Learn how to use PowerShell to manage and monitor Azure file shares backed up by the Azure Backup service.
4+
ms.topic: conceptual
5+
ms.date: 1/27/2020
6+
---
7+
8+
# Manage Azure file share backups with PowerShell
9+
10+
This article describes how to use Azure PowerShell to manage and monitor the Azure file shares that are backed up by the Azure Backup service.
11+
12+
## Modify the protection policy
13+
14+
To change the policy used for backing up the Azure file share, use [Enable-AzRecoveryServicesBackupProtection](https://docs.microsoft.com/powershell/module/az.recoveryservices/enable-azrecoveryservicesbackupprotection?view=azps-1.4.0). Specify the relevant backup item and the new backup policy.
15+
16+
The following example changes the **testAzureFS** protection policy from **dailyafs** to **monthlyafs**.
17+
18+
```powershell
19+
$monthlyafsPol = Get-AzRecoveryServicesBackupProtectionPolicy -Name "monthlyafs"
20+
$afsContainer = Get-AzRecoveryServicesBackupContainer -FriendlyName "testStorageAcct" -ContainerType AzureStorage
21+
$afsBkpItem = Get-AzRecoveryServicesBackupItem -Container $afsContainer -WorkloadType AzureFiles -Name "testAzureFS"
22+
Enable-AzRecoveryServicesBackupProtection -Item $afsBkpItem -Policy $monthlyafsPol
23+
```
24+
25+
## Track backup and restore jobs
26+
27+
On-demand backup and restore operations return a job along with an ID, as shown when you [ran an on-demand backup](#trigger-an-on-demand-backup). Use the [Get-AzRecoveryServicesBackupJobDetails](https://docs.microsoft.com/powershell/module/az.recoveryservices/get-azrecoveryservicesbackupjob?view=azps-1.4.0) cmdlet to track the job progress and details.
28+
29+
```powershell
30+
$job = Get-AzRecoveryServicesBackupJob -JobId 00000000-6c46-496e-980a-3740ccb2ad75 -VaultId $vaultID
31+
32+
$job | fl
33+
34+
35+
IsCancellable : False
36+
IsRetriable : False
37+
ErrorDetails : {Microsoft.Azure.Commands.RecoveryServices.Backup.Cmdlets.Models.AzureFileShareJobErrorInfo}
38+
ActivityId : 00000000-5b71-4d73-9465-8a4a91f13a36
39+
JobId : 00000000-6c46-496e-980a-3740ccb2ad75
40+
Operation : Restore
41+
Status : Failed
42+
WorkloadName : testAFS
43+
StartTime : 12/10/2018 9:56:38 AM
44+
EndTime : 12/10/2018 11:03:03 AM
45+
Duration : 01:06:24.4660027
46+
BackupManagementType : AzureStorage
47+
48+
$job.ErrorDetails
49+
50+
ErrorCode ErrorMessage Recommendations
51+
--------- ------------ ---------------
52+
1073871825 Microsoft Azure Backup encountered an internal error. Wait for a few minutes and then try the operation again. If the issue persists, please contact Microsoft support.
53+
```
54+
55+
## Manage Azure File Shares backup
56+
57+
### Stop Protection on a file share
58+
59+
There are two ways to stop protecting Azure file shares:
60+
61+
* Stop all future backup jobs and *delete* all recovery points
62+
* Stop all future backup jobs but *leave* the recovery points
63+
64+
There may be a cost associated with leaving the recovery points in storage, as the underlying snapshots created by Azure Backup will be retained. However, the benefit of leaving the recovery points is you can restore the file share later, if desired. For information about the cost of leaving the recovery points, see the [pricing details](https://azure.microsoft.com/pricing/details/storage/files/). If you choose to delete all recovery points, you can't restore the file share.
65+
66+
#### Stop Protection and retain recovery points
67+
68+
To stop protection while retaining data, use the [Disable-AzRecoveryServicesBackupProtection](https://docs.microsoft.com/powershell/module/az.recoveryservices/disable-azrecoveryservicesbackupprotection?view=azps-3.3.0) cmdlet.
69+
70+
The following example stops protection for the *afsfileshare* file share but retains all recovery points:
71+
72+
```powershell
73+
$vaultID = Get-AzRecoveryServicesVault -ResourceGroupName "afstesting" -Name "afstest" | select -ExpandProperty ID
74+
$bkpItem = Get-AzRecoveryServicesBackupItem -BackupManagementType AzureStorage -WorkloadType AzureFiles -Name "afsfileshare" -VaultId $vaultID
75+
Disable-AzRecoveryServicesBackupProtection -Item $bkpItem -VaultId $vaultID
76+
```
77+
78+
```output
79+
WorkloadName Operation Status StartTime EndTime JobID
80+
------------ --------- ------ --------- ------- -----
81+
afsfileshare DisableBackup Completed 1/26/2020 2:43:59 PM 1/26/2020 2:44:21 PM 98d9f8a1-54f2-4d85-8433-c32eafbd793f
82+
```
83+
84+
The Job ID attribute in the output corresponds to the Job ID of the job that is created by the backup service for your “stop protection” operation. To track the status of the job, use the [Get-AzRecoveryServicesBackupJob](https://docs.microsoft.com/powershell/module/az.recoveryservices/get-azrecoveryservicesbackupjob?view=azps-3.3.0) cmdlet.
85+
86+
#### Stop Protection without retaining recovery points
87+
88+
To stop protection without retaining recovery points, use the [Disable-AzRecoveryServicesBackupProtection](https://docs.microsoft.com/powershell/module/az.recoveryservices/disable-azrecoveryservicesbackupprotection?view=azps-3.3.0) cmdlet and add the **-RemoveRecoveryPoints** parameter.
89+
90+
The following example stops protection for the *afsfileshare* file share without retaining recovery points:
91+
92+
```powershell
93+
$vaultID = Get-AzRecoveryServicesVault -ResourceGroupName "afstesting" -Name "afstest" | select -ExpandProperty ID
94+
$bkpItem = Get-AzRecoveryServicesBackupItem -BackupManagementType AzureStorage -WorkloadType AzureFiles -Name "afsfileshare" -VaultId $vaultID
95+
Disable-AzRecoveryServicesBackupProtection -Item $bkpItem -VaultId $vaultID -RemoveRecoveryPoints
96+
```
97+
98+
```output
99+
WorkloadName Operation Status StartTime EndTime JobID
100+
------------ --------- ------ --------- ------- -----
101+
afsfileshare DeleteBackupData Completed 1/26/2020 2:50:57 PM 1/26/2020 2:51:39 PM b1a61c0b-548a-4687-9d15-9db1cc5bcc85
102+
```
103+
104+
## Next steps
105+
106+
[Learn about](manage-afs-backup.md) managing Azure file share backups in the Azure portal.

0 commit comments

Comments
 (0)