Restore a web app from a backup using Azure PowerShell
This sample script retrieves a previously completed backup from an existing web app and restores it by overwriting its content.
If needed, install the Azure PowerShell using the instruction found in the Azure PowerShell guide, and then run Connect-AzAccount to create a connection with Azure.
Sample script
Note
This article uses the Azure Az PowerShell module, which is the recommended PowerShell module for interacting with Azure. To get started with the Az PowerShell module, see Install Azure PowerShell. To learn how to migrate to the Az PowerShell module, see Migrate Azure PowerShell from AzureRM to Az.
$resourceGroupName = "myResourceGroup"
$webappname = "<replace-with-your-app-name>"
# List statuses of all backups that are complete or currently executing.
Get-AzWebAppBackupList -ResourceGroupName $resourceGroupName -Name $webappname
# Note the BackupID property of the backup you want to restore
# Get the backup object that you want to restore by specifying the BackupID
$backup = (Get-AzWebAppBackupList -ResourceGroupName $resourceGroupName -Name $webappname | where {$_.BackupId -eq '<replace-with-BackupID>'})
# Restore the app by overwriting it with the backup data
$backup | Restore-AzWebAppBackup -Overwrite
Clean up deployment
If you don't need the web app anymore, use the following command to remove the resource group, web app, and all related resources.
Remove-AzResourceGroup -Name $resourceGroupName -Force
Script explanation
This script uses the following commands. Each command in the table links to command specific documentation.
| Command | Notes |
|---|---|
| Get-AzWebAppBackupList | Gets a list of backups for a web app. |
| Restore-AzWebAppBackup | Restores a web app from a previously completed backup. |
Next steps
For more information on the Azure PowerShell module, see Azure PowerShell documentation.
Additional Azure PowerShell samples for Azure App Service Web Apps can be found in the Azure PowerShell samples.
Tilbakemeldinger
Send inn og vis tilbakemelding for