다음을 통해 공유


Azure PowerShell을 사용하여 백업에서 웹앱 복원

이 샘플 스크립트는 기존 웹앱에서 이전에 완료된 백업을 검색하고 해당 콘텐츠를 덮어쓰는 방법으로 복원합니다.

필요한 경우 Azure PowerShell 가이드에 있는 지침을 사용하여 Azure PowerShell을 설치한 다음, Connect-AzAccount를 실행하여 Azure에 연결합니다.

샘플 스크립트

참고 항목

Azure Az PowerShell 모듈을 사용하여 Azure와 상호 작용하는 것이 좋습니다. 시작하려면 Azure PowerShell 설치를 참조하세요. Az PowerShell 모듈로 마이그레이션하는 방법에 대한 자세한 내용은 Azure PowerShell을 AzureRM에서 Azure로 마이그레이션을 참조하세요.

$resourceGroupName = "myResourceGroup"
$webappname = "<replace-with-your-app-name>"
$targetResourceGroupName = "myResourceGroup"
$targetWebappName = "<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-AzWebAppBackup -ResourceGroupName $resourceGroupName -Name $webappname -BackupId '<replace-with-BackupID>')

# Get the storage account URL of the backup configuration
$url = (Get-AzWebAppBackupConfiguration -ResourceGroupName $resourceGroupName -Name $webappname).StorageAccountUrl

# Restore the app by overwriting it with the backup data
Restore-AzWebAppBackup -ResourceGroupName $resourceGroupName -Name $webappname -StorageAccountUrl $url -BlobName $backup.BlobName -Overwrite

배포 정리

더 이상 웹앱이 필요하지 않은 경우 다음 명령을 사용하여 리소스 그룹, 웹앱 및 모든 관련 리소스를 제거할 수 있습니다.

Remove-AzResourceGroup -Name $resourceGroupName -Force

스크립트 설명

이 스크립트는 다음 명령을 사용합니다. 테이블에 있는 각 명령은 명령에 해당하는 문서에 연결됩니다.

명령 주의
Get-AzWebAppBackupList 웹앱의 백업 목록을 가져옵니다.
Get-AzWebAppBackup 백업 ID를 사용하여 웹앱에 대한 백업을 가져옵니다.
Get-AzWebAppBackupConfiguration 웹앱의 백업 구성을 가져옵니다.
Restore-AzWebAppBackup 이전에 완료된 백업에서 웹앱을 복원합니다.

다음 단계

Azure PowerShell 모듈에 대한 자세한 내용은 Azure PowerShell 설명서를 참조하세요.

Azure App Service Web Apps에 대한 추가 Azure PowerShell 샘플은 Azure PowerShell 샘플에서 확인할 수 있습니다.