Note
Azure を操作するには、Azure Az PowerShell モジュールを使用することをお勧めします。 作業を始めるには、「Azure PowerShell をインストールする」を参照してください。 Az PowerShell モジュールに移行する方法については、「AzureRM から Az への Azure PowerShell の移行」を参照してください。
PowerShell スクリプトを使用して、仮想マシンの復元ポイントを作成できます。 Azure PowerShell AZ モジュールは、コマンド ラインやスクリプトから Azure リソースを作成および管理するために使用します。
VM の復元ポイントを定期的に作成することにより、データを保護し、ダウンタイムが延びるのを防ぐことができます。 この記事では、Az.Compute モジュールを使用して VM 復元ポイントを作成し、復元ポイントからディスクを除外する方法について説明します。 また、Azure CLI を使用するかまたは Azure portal で VM 復元ポイントを作成することもできます。
このチュートリアルでは、以下の内容を学習します。
前提条件
手順 1: VM 復元ポイント コレクションを作成する
New-AzRestorePointCollection コマンドレットを使用して、VM 復元ポイント コレクションを作成します。
New-AzRestorePointCollection -ResourceGroupName ExampleRG -Name ExampleRPC -VmId “/subscriptions/{SubscriptionId}/resourcegroups/ ExampleRG/providers/microsoft.compute/virtualmachines/Example-vm-1” -Location “WestEurope”
手順 2: VM 復元ポイントを作成する
New-AzRestorePoint コマンドレットを次に示すように使用して、VM 復元ポイントを作成します。
New-AzRestorePoint -ResourceGroupName ExampleRG -RestorePointCollectionName ExampleRPC -Name ExampleRP
クラッシュ整合性復元ポイントを作成するには、オプションのパラメータ "ConsistencyMode" を "CrashConsistent" に設定します。 現在、この機能はプレビュー段階にあります。
復元ポイントからディスクを除外する
復元ポイントの一部にしたくない特定のディスクを、次のように -DisksToExclude
パラメーターを使用して除外します。
New-AzRestorePoint -ResourceGroupName ExampleRG -RestorePointCollectionName ExampleRPC -Name ExampleRP -DisksToExclude “/subscriptions/{SubscriptionId}/resourcegroups/ ExampleRG/providers/Microsoft.Compute/disks/example-vm-1-data_disk_1”
手順 3: VM 復元ポイントの作成の状態を追跡する
Get-AzRestorePoint コマンドレットを次のように使用して、VM 復元ポイント作成の進行状況を追跡できます。
Get-AzRestorePoint -ResourceGroupName ExampleRG -RestorePointCollectionName ExampleRPC -Name ExampleRP
VM 復元ポイントから VM を復元する
VM の復元ポイントから VM を復元するには、最初に各ディスク復元ポイントから個々のディスクを復元します。 ARM テンプレートを使用して、すべてのディスクと共に完全な VM を復元することもできます。
# Create Disks from disk restore points
$restorePoint = Get-AzRestorePoint -ResourceGroupName ExampleRG -RestorePointCollectionName ExampleRPC -Name ExampleRP
$osDiskRestorePoint = $restorePoint.SourceMetadata.StorageProfile.OsDisk.DiskRestorePoint.Id
$dataDisk1RestorePoint = $restorePoint.sourceMetadata.storageProfile.dataDisks[0].diskRestorePoint.id
$dataDisk2RestorePoint = $restorePoint.sourceMetadata.storageProfile.dataDisks[1].diskRestorePoint.id
New-AzDisk -DiskName “ExampleOSDisk” (New-AzDiskConfig -Location eastus -CreateOption Restore -SourceResourceId $osDiskRestorePoint) -ResourceGroupName ExampleRg
New-AzDisk -DiskName “ExampleDataDisk1” (New-AzDiskConfig -Location eastus -CreateOption Restore -SourceResourceId $dataDisk1RestorePoint) -ResourceGroupName ExampleRg
New-AzDisk -DiskName “ExampleDataDisk2” (New-AzDiskConfig -Location eastus -CreateOption Restore -SourceResourceId $dataDisk2RestorePoint) -ResourceGroupName ExampleRg
ディスクを作成した後に、新しい VM を作成して、復元されたこれらのディスクを新しく作成した VM にアタッチします。
次のステップ
Azure での仮想マシンのバックアップと復元のオプションに関する詳細は、こちらをご覧ください。