在 Azure 備份 中使用 REST API 追蹤備份和還原作業
本文說明如何在 Azure 備份 中使用 REST API 監視備份和還原作業。
Azure 備份 服務會觸發在各種案例中背景執行的作業,例如觸發備份、還原作業、停用備份。 您可以使用工作的識別碼加以追蹤。
從作業 (Operation) 擷取作業 (Job) 資訊
觸發備份之類的作業一律會傳回 jobID。 例如:觸發備份 REST API 作業的最後回應如下所示:
{
"id": "cd153561-20d3-467a-b911-cc1de47d4763",
"name": "cd153561-20d3-467a-b911-cc1de47d4763",
"status": "Succeeded",
"startTime": "2018-09-12T02:16:56.7399752Z",
"endTime": "2018-09-12T02:16:56.7399752Z",
"properties": {
"objectType": "OperationStatusJobExtendedInfo",
"jobId": "41f3e94b-ae6b-4a20-b422-65abfcaf03e5"
}
}
Azure VM 備份作業是由 "jobId" 欄位來識別,而且可如這裡所述使用簡單的 GET 要求進行追蹤。
追蹤作業
GET https://management.azure.com/Subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{vaultName}/backupJobs/{jobName}?api-version=2019-05-13
{jobName}
是上面提及的 "jobId"。 回應一律為「200 確定」,其 [狀態] 欄位會指出作業的目前狀態。 完成或 CompletedWithWarnings 之後,[extendedInfo] 區段會顯示作業的詳細數據。
回應
名稱 | 類型 | 描述 |
---|---|---|
200 OK | JobResource | 確定 |
範例回應
一旦 GET URI 提交完成,就會傳回 200 (確定) 回應。
HTTP/1.1 200 OK
Pragma: no-cache
X-Content-Type-Options: nosniff
x-ms-request-id: e9702101-9da2-4681-bdf3-a54e17329a56
x-ms-client-request-id: ba4dff71-1655-4c1d-a71f-c9869371b18b; ba4dff71-1655-4c1d-a71f-c9869371b18b
Strict-Transport-Security: max-age=31536000; includeSubDomains
x-ms-ratelimit-remaining-subscription-reads: 14989
x-ms-correlation-request-id: e9702101-9da2-4681-bdf3-a54e17329a56
x-ms-routing-request-id: SOUTHINDIA:20180521T102317Z:e9702101-9da2-4681-bdf3-a54e17329a56
Cache-Control: no-cache
Date: Mon, 21 May 2018 10:23:17 GMT
Server: Microsoft-IIS/8.0
X-Powered-By: ASP.NET
{
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/Default-RecoveryServices-ResourceGroup-centralindia/providers/microsoft.recoveryservices/vaults/abdemovault/backupJobs/7ddead57-bcb9-4269-ac31-6a1b57588700",
"name": "7ddead57-bcb9-4269-ac31-6a1b57588700",
"type": "Microsoft.RecoveryServices/vaults/backupJobs",
"properties": {
"jobType": "AzureIaaSVMJob",
"duration": "00:20:23.0896697",
"actionsInfo": [
1
],
"virtualMachineVersion": "Compute",
"extendedInfo": {
"tasksList": [
{
"taskId": "Take Snapshot",
"duration": "00:00:00",
"status": "Completed"
},
{
"taskId": "Transfer data to vault",
"duration": "00:00:00",
"status": "Completed"
}
],
"propertyBag": {
"VM Name": "uttestvmub1",
"Backup Size": "2332 MB"
}
},
"entityFriendlyName": "uttestvmub1",
"backupManagementType": "AzureIaasVM",
"operation": "Backup",
"status": "Completed",
"startTime": "2018-05-21T08:35:40.9488967Z",
"endTime": "2018-05-21T08:56:04.0385664Z",
"activityId": "7df8e874-1d66-4f81-8e91-da2fe054811d"
}
}
}