Share via


Azure CLI を使用して仮想マシンの復元ポイントを作成する

VM の復元ポイントを定期的に作成することにより、データを保護し、ダウンタイムが延びるのを防ぐことができます。 Azure CLI を使用して、VM の復元ポイントを作成し、復元ポイントの作成中に ディスクを除外することができます。 Azure CLI は、コマンド ラインまたはスクリプトを使用して Azure リソースを作成および管理するために使用します。 また、Azure portal または PowerShell を使用して VM 復元ポイントを作成することもできます。

az restore-point モジュールは、コマンド ラインやスクリプトで復元ポイントを作成および管理するために使用されます。

このチュートリアルでは、以下の内容を学習します。

前提条件

  • Azure Cloud Shell で Bash 環境を使用します。 詳細については、「Azure Cloud Shell の Bash のクイックスタート」を参照してください。

  • CLI リファレンス コマンドをローカルで実行する場合、Azure CLI をインストールします。 Windows または macOS で実行している場合は、Docker コンテナーで Azure CLI を実行することを検討してください。 詳細については、「Docker コンテナーで Azure CLI を実行する方法」を参照してください。

    • ローカル インストールを使用する場合は、az login コマンドを使用して Azure CLI にサインインします。 認証プロセスを完了するには、ターミナルに表示される手順に従います。 その他のサインイン オプションについては、Azure CLI でのサインインに関するページを参照してください。

    • 初回使用時にインストールを求められたら、Azure CLI 拡張機能をインストールします。 拡張機能の詳細については、Azure CLI で拡張機能を使用する方法に関するページを参照してください。

    • az version を実行し、インストールされているバージョンおよび依存ライブラリを検索します。 最新バージョンにアップグレードするには、az upgrade を実行します。

手順 1: VM 復元ポイント コレクションを作成する

次に示すように、az restore-point collection create コマンドを使用して VM 復元ポイント コレクションを作成します。

az restore-point collection create --location "norwayeast" --source-id "/subscriptions/{subscription-id}/resourceGroups/ExampleRg/providers/Microsoft.Compute/virtualMachines/ExampleVM" --tags myTag1="tagValue1" --resource-group "ExampleRg" --collection-name "ExampleRpc"

手順 2: VM 復元ポイントを作成する

az restore-point create コマンドを次のように使用して、VM 復元ポイントを作成します。

az restore-point create --resource-group "ExampleRg" --collection-name "ExampleRpc" --name "ExampleRp"

クラッシュ整合性の復元ポイントを作成するには、省略可能なパラメータ "consistency-mode" を "CrashConsistent" に設定します。 現在、この機能はプレビュー段階にあります。

復元ポイントの作成時にディスクを除外する

復元ポイントの一部にしたくないディスクを、次のように --exclude-disks パラメーターを使用して除外します。

az restore-point create --exclude-disks "/subscriptions/{subscription-id}/resourceGroups/ExampleRg/providers/Microsoft.Compute/disks/ExampleDisk1" --resource-group "ExampleRg" --collection-name "ExampleRpc" --name "ExampleRp"

手順 3: VM 復元ポイントの作成の状態を追跡する

az restore-point show コマンドを使用して、VM 復元ポイント作成の進行状況を追跡します。

az restore-point show --resource-group "ExampleRg" --collection-name "ExampleRpc" --name "ExampleRp"

VM 復元ポイントから VM を復元する

VM の復元ポイントから VM を復元するには、最初に各ディスク復元ポイントから個々のディスクを復元します。 ARM テンプレートを使用して、すべてのディスクと共に完全な VM を復元することもできます。

# Create Disks from disk restore points 
$osDiskRestorePoint = az restore-point show --resource-group "ExampleRg" --collection-name "ExampleRpc" --name "ExampleRp" --query "sourceMetadata.storageProfile.dataDisks[0].diskRestorePoint.id"
$dataDisk1RestorePoint = az restore-point show --resource-group "ExampleRg" --collection-name "ExampleRpcTarget" --name "ExampleRpTarget" –query "sourceMetadata.storageProfile.dataDisks[0].diskRestorePoint.id"
$dataDisk2RestorePoint = az restore-point show --resource-group "ExampleRg" --collection-name "ExampleRpcTarget" --name "ExampleRpTarget" –query "sourceMetadata.storageProfile.dataDisks[0].diskRestorePoint.id"
 
az disk create --resource-group “ExampleRg” --name “ExampleOSDisk” --sku Premium_LRS --size-gb 128 --source $osDiskRestorePoint

az disk create --resource-group “ExampleRg” --name “ExampleDataDisk1” --sku Premium_LRS --size-gb 128 --source $dataDisk1RestorePoint

az disk create --resource-group “ExampleRg” --name “ExampleDataDisk1” --sku Premium_LRS --size-gb 128 --source $dataDisk2RestorePoint

ディスクを作成したら、新しい VM を作成して、復元されたこれらのディスクを新しく作成した VM にアタッチします。

次のステップ

Azure での仮想マシンのバックアップと復元のオプションに関する詳細は、こちらをご覧ください。