使用 REST API 跟踪备份和还原作业Track backup and restore jobs using REST API

Azure 备份服务会触发各种情况下在后台运行的作业,例如触发备份、执行还原操作以及禁用备份。Azure Backup service triggers jobs that run in background in various scenarios such as triggering backup, restore operations, disabling backup. 可以使用作业的 ID 跟踪这些作业。These jobs can be tracked using their IDs.

从操作中提取作业信息Fetch Job information from operations

操作(例如触发备份)将始终返回 jobID。An operation such as triggering backup will always return a jobID. 例如:触发备份 REST API 操作的最终响应如下所示:For example: The final response of a trigger backup REST API operation is as follows:

{
  "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 请求进行跟踪。The Azure VM backup job is identified by "jobId" field and can be tracked as mentioned here using a simple GET request.

跟踪作业Tracking the job

GET https://management.chinacloudapi.cn/Subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{vaultName}/backupJobs/{jobName}?api-version=2019-05-13

{jobName} 是上面提到的“jobId”。The {jobName} is "jobId" mentioned above. 响应始终为 200 OK,并且始终包含指示作业的当前状态的“status”字段。The response is always 200 OK with the "status" field indicating the current status of the job. 当状态为“Completed”或“CompletedWithWarnings”之后,“extendedInfo”部分将显示关于作业的更多详细信息。Once it's "Completed" or "CompletedWithWarnings", the 'extendedInfo' section reveals more details about the job.

响应Response

名称Name 类型Type 说明Description
200 正常200 OK JobResourceJobResource OKOK

示例响应Example response

提交 GET URI 后,将返回 200 (OK) 响应。Once the GET URI is submitted, a 200 (OK) response is returned.

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"
  }
}
}