page_type | languages | products | description | urlFragment | ||
---|---|---|---|---|---|---|
sample |
|
|
Automate On-demand backup for Azure File Shares using PowerShell for Azure Backup |
Use-PowerShell-for-long-term-retention-of-Azure-Files-Backup |
Automate On-demand backup for Azure File Shares using PowerShell for Azure Backup
Create recovery points while backing up Azure Files with up to 10 years of retention
Create an Automation resource with “Run As” account
Import modules from Gallery in the Automation resource.
Import the following modules from the Modules gallery in the order given below:
- AzureRM.Profile
- AzureRM.RecoveryServices
- AzureRM.RecoveryServices.Backup
Create PowerShell Runbooks in the Automation Resource. You can create multiple Runbooks based on which set of File shares you want to protect.
Edit the Runbook and write script to choose which file shares to take a backup. You can create scripts that suit your requirements.
- Save the script
- Test the script using “Test Pane”
- Publish the Runbook
A sample script to backup all file shares in a subscription is provided in the repository
Schedule the Runbook. While scheduling the Runbook, you can pass on the parameters required for the PowerShell Script. The sample script takes the retention as an input. So, if you need to schedule a weekly snapshot and retain for 8 weeks, create a weekly schedule as mentioned below and specify the retention as 56 days (8 weeks). You can create monthly and yearly schedules (run every 12 months) in a similar manner. You can monitor the success/failure of these backups using the “Jobs” tab of Runbooks