Skip to content

Commit

Permalink
restore web app scripts (Azure#156)
Browse files Browse the repository at this point in the history
  • Loading branch information
cephalin authored and erickson-doug committed Nov 21, 2018
1 parent 30d0f63 commit 77c8876
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 2 deletions.
27 changes: 27 additions & 0 deletions app-service/backup-restore-diff-sub/backup-restore-diff-sub.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
$resourceGroupNameSub1 = "<replace-with-your-group-name>"
$resourceGroupNameSub2 = "<replace-with-desired-new-group-name>"
$webAppNameSub1 = "<replace-with-your-app-name>"
$webAppNameSub2 = "<replace-with-desired-new-app-name>"
$appServicePlanSub2 = "<replace-with-desired-new-plan-name>"
$locationSub2 = "West Europe"


# Log into the subscription with the backup
Add-AzureRmAccount

# List statuses of all backups that are complete or currently executing.
Get-AzureRmWebAppBackupList -ResourceGroupName $resourceGroupNameSub1 -Name $webAppNameSub1

# 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-AzureRmWebAppBackupList -ResourceGroupName $resourceGroupNameSub1 -Name $webAppNameSub1 | where {$_.BackupId -eq <replace-with-BackupID>})

# Log into the subscription that you want to restore the app to
Add-AzureRmAccount

# Create a new web app
New-AzureRmWebApp -ResourceGroupName $resourceGroupNameSub2 -AppServicePlan $appServicePlanSub2 -Name $webAppNameSub2 -Location $locationSub2

# Restore the app by overwriting it with the backup data
Restore-AzureRmWebAppBackup -ResourceGroupName $resourceGroupNameSub2 -Name $webAppNameSub2 -StorageAccountUrl $backup.StorageAccountUrl -BlobName $backup.BlobName -Overwrite
4 changes: 2 additions & 2 deletions app-service/backup-restore/backup-restore.ps1
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
$resourceGroupName = "myResourceGroup"
$webappname = "<replace-with-your-app-name>"


# List statuses of all backups that are complete or currently executing.
Get-AzureRmWebAppBackupList -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-AzureRmWebAppBackup -ResourceGroupName $resourceGroupName -Name $webappname `
-BackupId <replace-with-BackupID>
$backup = (Get-AzureRmWebAppBackupList -ResourceGroupName $resourceGroupName -Name $webappname | where {$_.BackupId -eq <replace-with-BackupID>})

# Restore the app by overwriting it with the backup data
$backup | Restore-AzureRmWebAppBackup -Overwrite

0 comments on commit 77c8876

Please sign in to comment.