|
2 | 2 | title: Back up an Azure file share by using PowerShell
|
3 | 3 | description: In this article, learn how to back up an Azure Files file share by using the Azure Backup service and PowerShell.
|
4 | 4 | ms.topic: how-to
|
5 |
| -ms.date: 07/18/2024 |
| 5 | +ms.date: 12/10/2024 |
6 | 6 | ms.custom: devx-track-azurepowershell
|
7 | 7 | ms.service: azure-backup
|
8 | 8 | author: AbhishekMallick-MS
|
@@ -152,45 +152,12 @@ A backup policy specifies the schedule for backups, and how long backup recovery
|
152 | 152 |
|
153 | 153 | A backup policy is associated with at least one retention policy. A retention policy defines how long a recovery point is kept before it's deleted. You can configure backups with daily, weekly, monthly, or yearly retention. With multiple backups policy, you can also configure backups hourly retention.
|
154 | 154 |
|
155 |
| -**Choose a policy type**: |
156 |
| - |
157 |
| -# [Daily backup policy](#tab/daily-backup-policy) |
158 |
| - |
159 |
| -Here are some cmdlets for backup policies: |
160 |
| - |
161 |
| -* View the default backup policy retention by using [Get-AzRecoveryServicesBackupRetentionPolicyObject](/powershell/module/az.recoveryservices/get-azrecoveryservicesbackupretentionpolicyobject). |
162 |
| -* View the default backup policy schedule by using [Get-AzRecoveryServicesBackupSchedulePolicyObject](/powershell/module/az.recoveryservices/get-azrecoveryservicesbackupschedulepolicyobject). |
163 |
| -* Create a new backup policy by using [New-AzRecoveryServicesBackupProtectionPolicy](/powershell/module/az.recoveryservices/set-azrecoveryservicesbackupprotectionpolicy). You enter the schedule and retention policy objects as input. |
164 |
| - |
165 |
| -By default, a start time is defined in the schedule policy object. Use the following example to change the start time to the desired start time. The desired start time should be in Universal Coordinated Time (UTC). The example assumes that the desired start time is 01:00 AM UTC for daily backups. |
166 |
| - |
167 |
| -```azurepowershell-interactive |
168 |
| -$schPol = Get-AzRecoveryServicesBackupSchedulePolicyObject -WorkloadType "AzureFiles" |
169 |
| -$UtcTime = Get-Date -Date "2019-03-20 01:30:00Z" |
170 |
| -$UtcTime = $UtcTime.ToUniversalTime() |
171 |
| -$schpol.ScheduleRunTimes[0] = $UtcTime |
172 |
| -``` |
173 |
| - |
174 |
| -> [!IMPORTANT] |
175 |
| -> You need to provide the start time in 30-minute multiples only. In the preceding example, it can be only "01:00:00" or "02:30:00". The start time can't be "01:15:00". |
176 |
| -
|
177 |
| -The following example stores the schedule policy and the retention policy in variables. It then uses those variables as parameters for a new policy (**NewAFSPolicy**). **NewAFSPolicy** takes a daily backup and retains it for 30 days. |
178 |
| - |
179 |
| -```azurepowershell-interactive |
180 |
| -$schPol = Get-AzRecoveryServicesBackupSchedulePolicyObject -WorkloadType "AzureFiles" |
181 |
| -$retPol = Get-AzRecoveryServicesBackupRetentionPolicyObject -WorkloadType "AzureFiles" |
182 |
| -New-AzRecoveryServicesBackupProtectionPolicy -Name "NewAFSPolicy" -WorkloadType "AzureFiles" -RetentionPolicy $retPol -SchedulePolicy $schPol |
183 |
| -``` |
184 |
| - |
185 |
| -The output is similar to the following: |
186 |
| - |
187 |
| -```azurepowershell-interactive |
188 |
| -Name WorkloadType BackupManagementType BackupTime DaysOfWeek |
189 |
| ----- ------------ -------------------- ---------- ---------- |
190 |
| -NewAFSPolicy AzureFiles AzureStorage 10/24/2019 1:30:00 AM |
191 |
| -``` |
192 |
| - |
193 |
| -# [Multiple backups policy](#tab/multiple-backups-policy) |
| 155 | +>[!Important] |
| 156 | +>The following cmdlets are used for the Backup policies: |
| 157 | +> |
| 158 | +>- View the default backup policy retention by using `Get-AzRecoveryServicesBackupRetentionPolicyObject`. |
| 159 | +>- View the default backup policy schedule by using `Get-AzRecoveryServicesBackupSchedulePolicyObject`. |
| 160 | +>- Create a new backup policy by using `New-AzRecoveryServicesBackupProtectionPolicy`. Provide the schedule and retention policy objects as inputs. |
194 | 161 |
|
195 | 162 | To create a backup policy that configures multiple backups a day, follow these steps:
|
196 | 163 |
|
@@ -230,6 +197,14 @@ To create a backup policy that configures multiple backups a day, follow these s
|
230 | 197 | $schPol.ScheduleRunTimeZone=$timeZone.Id
|
231 | 198 | ```
|
232 | 199 |
|
| 200 | + To reate a policy with daily schedule, run the following cmdlet: |
| 201 | + |
| 202 | + ```azurepowershell |
| 203 | + $UtcTime = Get-Date -Date "2019-03-20 01:30:00Z" |
| 204 | + $UtcTime = $UtcTime.ToUniversalTime() |
| 205 | + $schpol.ScheduleRunTimes[0] = $UtcTime |
| 206 | + ``` |
| 207 | + |
233 | 208 | 1. Fetch the retention policy object using following cmdlet:
|
234 | 209 |
|
235 | 210 | ```azurepowershell-interactive
|
@@ -260,7 +235,6 @@ To create a backup policy that configures multiple backups a day, follow these s
|
260 | 235 | testing AzureFiles AzureStorage Hourly 12/22/2021 8:00:00 AM 4 12 Russia Time Zone 11
|
261 | 236 |
|
262 | 237 | ```
|
263 |
| ---- |
264 | 238 |
|
265 | 239 | ## Enable backup
|
266 | 240 |
|
|
0 commit comments