本文說明如何使用 Azure 備份透過 REST API 來備份 Azure VM 中的 SQL server 資料庫。
注意
若要深入了解支援的設定和案例,請參閱 SQL 備份支援矩陣圖。
必要條件
- 復原服務保存庫
- 用於設定 SQL 資料庫備份的原則。
如需有關如何建立新保存庫和原則的詳細資訊,請參閱建立保存庫和建立原則 REST API 教學課程。
可使用下列資源:
- 復原服務保存庫:SQLServer2012
- 原則:HourlyLogBackup
- 資源群組:SQLServerSelfHost
為 Azure VM 中未受保護的 SQL Server 資料庫設定備份
探索未受保護的 SQL Server 資料庫
保存庫需要探索訂閱中的 Azure VM,而這些 VM 全都有可備份至復原服務保存庫的 SQL 資料庫。 若要擷取詳細資料,請觸發重新整理作業。 此為非同步的 POST 作業,用以保證保存庫取得並快取處理目前訂閱中所有受保護 SQL 資料庫的最新清單。 快取處理資料庫之後,復原服務就可以存取並保護資料庫。
POST https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{vaultResourceGroupName}/providers/microsoft.recoveryservices/vaults/{vaultName}/backupFabrics/{fabricName}/refreshContainers?api-version=2016-12-01&$filter={$filter}
POST URI 有 {subscriptionId}、{vaultName}、{vaultresourceGroupName} 和{fabricName} 參數。 在下列範例中,各參數的值如下:
-
{fabricName}:Azure -
{vaultName}:SQLServer2012 -
{vaultresourceGroupName}:SQLServerSelfHost -
$filter:backupManagementType eq 'AzureWorkload'
由於 URI3 中已指定所有必要參數,不需要另外的要求本文。
POST https://management.azure.com/subscriptions/00000000-0000-0000-0000-0000000000/resourceGroups/SQLServerSelfHost/providers/microsoft.recoveryservices/vaults/SQLServer2012/backupFabrics/Azure/refreshContainers?api-version=2016-12-01&$filter=backupManagementType eq 'AzureWorkload'
對重新整理作業的回應
重新整理作業為非同步作業。 這表示此作業會建立另一項需要個別追蹤的作業。
該作業傳回兩個回應:在建立另一項作業時傳回 202 (已接受),並在該作業完成時傳回 200 (OK)。
對重新整理作業的回應範例
提交 POST 要求之後,傳回 202 (已接受) 回應。
HTTP/1.1 202 Accepted
Pragma: no-cache
Retry-After: 60
X-Content-Type-Options: nosniff
x-ms-request-id: a85ee4a2-56d7-4477-b29c-d140a8bb90fe
x-ms-client-request-id: 4653a4ed-ffbe-4492-ae7d-3e1ab03722af; 4653a4ed-ffbe-4492-ae7d-3e1ab03722af
Strict-Transport-Security: max-age=31536000; includeSubDomains
x-ms-ratelimit-remaining-subscription-writes: 1199
x-ms-correlation-request-id: a85ee4a2-56d7-4477-b29c-d140a8bb90fe
x-ms-routing-request-id: SOUTHINDIA:20180528T075517Z:a85ee4a2-56d7-4477-b29c-d140a8bb90fe
Cache-Control: no-cache
Date: Mon, 28 May 2018 07:55:16 GMT
Location: https://management.azure.com/subscriptions/00000000-0000-0000-0000-0000000000/resourceGroups/SQLServerSelfHost/providers/microsoft.recoveryservices/vaults/SQLServer2012/backupFabrics/Azure/operationResults/a60bfc5e-e237-4ead-be5c-b845e9566ea8?api-version=2016-12-01
X-Powered-By: ASP.NET
透過簡單的 GET 命令,使用 Location 標頭來追蹤產生的作業。
GET https://management.azure.com/subscriptions/00000000-0000-0000-0000-0000000000/resourceGroups/SQLServerSelfHost/providers/microsoft.recoveryservices/vaults/SQLServer2012/backupFabrics/Azure/operationResults/a60bfc5e-e237-4ead-be5c-b845e9566ea8?api-version=2016-12-01
找到所有 SQL 資料庫之後,GET 命令傳回 200 (沒有內容) 回應。 現在,保存庫可以探索訂閱內的任何 VM,而這些 VM 都有可備份的 SQL 資料庫。
HTTP/1.1 204 NoContent
Pragma: no-cache
X-Content-Type-Options: nosniff
x-ms-request-id: 55ae46bb-0d61-4284-a408-bcfaa36af643
x-ms-client-request-id: b5ffa56f-a521-48a4-91b2-e3bc1e3f1110; b5ffa56f-a521-48a4-91b2-e3bc1e3f1110
Strict-Transport-Security: max-age=31536000; includeSubDomains
x-ms-ratelimit-remaining-subscription-reads: 14968
x-ms-correlation-request-id: 55ae46bb-0d61-4284-a408-bcfaa36af643
x-ms-routing-request-id: SOUTHINDIA:20180528T075607Z:55ae46bb-0d61-4284-a408-bcfaa36af643
Cache-Control: no-cache
Date: Mon, 28 May 2018 07:56:06 GMT
X-Powered-By: ASP.NET
列出哪些 VM 有可透過復原服務保存庫來備份的 SQL 資料庫
若要確認快取處理已完成,請列出訂閱中的 VM,而這些 VM 全都有可透過復原服務保存庫來備份的 SQL 資料庫。 然後,在回應中找出所需的儲存體帳戶。 這是使用 GET ProtectableContainers 作業來完成。
GET https://management.azure.com/subscriptions/00000000-0000-0000-0000-0000000000/resourceGroups/SQLServerSelfHost/providers/microsoft.recoveryservices/vaults/SQLServer2012/backupFabrics/Azure/protectableContainers?api-version=2016-12-01&$filter=backupManagementType eq 'AzureWorkload'
注意
GET URI 具備所有必要參數。 不需任何額外的要求本文。
回應本文的範例:
{
"value": [
{
"id": "/subscriptions/00000000-0000-0000-0000-0000000000/resourceGroups/SQLServerSelfHost/providers/microsoft.recoveryservices/vaults/SQLServer2012/backupFabrics/Azure/protectableContainers/VMAppContainer;Compute;SQLServerPMDemo;ad-primary-dc",
"name": "VMAppContainer;Compute;SQLServerPMDemo;ad-primary-dc",
"type": "Microsoft.RecoveryServices/vaults/backupFabrics/protectableContainers",
"properties": {
"friendlyName": "ad-primary-dc",
"backupManagementType": "AzureWorkload",
"protectableContainerType": "VMAppContainer",
"healthStatus": "Healthy",
"containerId": "/subscriptions/00000000-0000-0000-0000-0000000000/resourceGroups/SQLServerPMDemo/providers/Microsoft.Compute/virtualMachines/ad-primary-dc"
}
},
{
"id": "/subscriptions/00000000-0000-0000-0000-0000000000/resourceGroups/SQLServerSelfHost/providers/microsoft.recoveryservices/vaults/SQLServer2012/backupFabrics/Azure/protectableContainers/VMAppContainer;Compute;SQLServerPMDemo;ad-secondry-dc",
"name": "VMAppContainer;Compute;SQLServerPMDemo;ad-secondry-dc",
"type": "Microsoft.RecoveryServices/vaults/backupFabrics/protectableContainers",
"properties": {
"friendlyName": "ad-secondry-dc",
"backupManagementType": "AzureWorkload",
"protectableContainerType": "VMAppContainer",
"healthStatus": "Healthy",
"containerId": "/subscriptions/00000000-0000-0000-0000-0000000000/resourceGroups/SQLServerPMDemo/providers/Microsoft.Compute/virtualMachines/ad-secondry-dc"
}
},
{
"id": "/subscriptions/00000000-0000-0000-0000-0000000000/resourceGroups/SQLServerSelfHost/providers/microsoft.recoveryservices/vaults/SQLServer2012/backupFabrics/Azure/protectableContainers/VMAppContainer;Compute;SQLServerPMDemo;sqlserver-0",
"name": "VMAppContainer;Compute;SQLServerPMDemo;sqlserver-0",
"type": "Microsoft.RecoveryServices/vaults/backupFabrics/protectableContainers",
"properties": {
"friendlyName": "sqlserver-0",
"backupManagementType": "AzureWorkload",
"protectableContainerType": "VMAppContainer",
"healthStatus": "Healthy",
"containerId": "/subscriptions/00000000-0000-0000-0000-0000000000/resourceGroups/SQLServerPMDemo/providers/Microsoft.Compute/virtualMachines/sqlserver-0"
}
}
]
}
由於可在回應本文中以自訂名稱找到 VM,因此以上執行的重新整理作業成功。 現在,復原服務保存庫可以在相同的訂閱中,成功探索具有未受保護 SQL 資料庫的 VM。
向復原服務保存庫註冊 VM
您必須向復原服務保存庫註冊 VM,才能讓 Azure 備份服務與 VM 內的 SQL 資料庫互動 (使用 Name 欄位中的值來識別 Azure VM 容器)。 您必須在 JSON 要求中提供值,如此才能從列出可受保護容器結果的屬性封包中取得 HTTP 要求本文。
PUT https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.recoveryservices/vaults/{vaultName}/backupFabrics/Azure/protectionContainers/{containerName}?api-version=2016-12-01
設定 URI 的變數,如下所示:
-
{resourceGroupName}- SQLServerSelfHost -
{fabricName}- 天藍色 -
{vaultName}- SQLServer2012 -
{containerName}- 這是 GET ProtectableContainers 作業回應本文中的 name 屬性。 在我們的範例中,name 屬性是 VMAppContainer;Compute;SQLServerPMDemo;sqlserver-0。
注意
請一律採用回應的 name 屬性並填入此要求中。 不要採用硬式編碼或建立容器-名稱格式。 如果建立或採用硬式編碼,未來容器-名稱格式變更時,API 呼叫將會失敗。
PUT https://management.azure.com/subscriptions/00000000-0000-0000-0000-0000000000/resourceGroups/SQLServerSelfHost/providers/microsoft.recoveryservices/vaults/SQLServer2012/backupFabrics/Azure/protectionContainers/VMAppContainer;Compute;SQLServerPMDemo;sqlserver-0?api-version=2016-12-01
建立的要求本文如下:
{
"properties": {
"backupManagementType": "AzureWorkload",
"friendlyName": "sqlserver-0",
"containerType": "VMAppContainer",
"sourceResourceId": "/subscriptions/00000000-0000-0000-0000-0000000000/resourceGroups/SQLServerSelfHost/providers/microsoft.recoveryservices/vaults/SQLServer2012/backupFabrics/Azure/protectableContainers/VMAppContainer;Compute;SQLServerPMDemo;sqlserver-0",
"workloadType": "SQLDataBase"
}
}
如需要求本文的完整定義清單及其他詳細資料,請參閱 ProtectionContainers-Register。
此為非同步作業,並傳回兩個回應:接受作業時傳回 202 (已接受),作業完成時傳回 200 (OK)。 若要追蹤作業狀態,請使用 location 標頭來取得作業的最新狀態。
GET https://management.azure.com/subscriptions/00000000-0000-0000-0000-0000000000/resourceGroups/SQLServerSelfHost/providers/microsoft.recoveryservices/vaults/SQLServer2012/backupFabrics/Azure/protectionContainers/VMAppContainer;Compute;SQLServerPMDemo;sqlserver-0/operationResults/2a72d206-b4d8-4c59-89ef-ef3283132237?api-version=2016-12-01
作業完成時的回應本文範例:
{
"id": "/subscriptions/00000000-0000-0000-0000-0000000000/resourceGroups/SQLServerSelfHost/providers/microsoft.recoveryservices/vaults/SQLServer2012/backupFabrics/Azure/protectionContainers/VMAppContainer;Compute;SQLServerPMDemo;sqlserver-0",
"name": "VMAppContainer;Compute;SQLServerPMDemo;sqlserver-0",
"type": "Microsoft.RecoveryServices/vaults/backupFabrics/protectionContainers",
"properties": {
"sourceResourceId": "/subscriptions/00000000-0000-0000-0000-0000000000/resourceGroups/SQLServerPMDemo/providers/Microsoft.Compute/virtualMachines/sqlserver-0",
"lastUpdatedTime": "2018-05-28T08:33:14.7304852Z",
"extendedInfo": {
"hostServerName": "sqlserver-0.shopkart.com",
"inquiryInfo": {
"status": "Success",
"errorDetail": {
"code": "Success",
"message": "",
"recommendations": [
""
]
},
"inquiryDetails": [
{
"type": "SQL",
"itemCount": 5,
"inquiryValidation": {
"status": "Success",
"errorDetail": {
"code": "Success",
"message": "",
"recommendations": [
""
]
}
}
}
]
}
},
"friendlyName": "sqlserver-0",
"backupManagementType": "AzureWorkload",
"registrationStatus": "Registered",
"healthStatus": "Healthy",
"containerType": "VMAppContainer",
"protectableObjectType": "VMAppContainer"
}
}
您可以從回應本文的 registrationstatus 參數值來驗證註冊是否成功。 我們的案例中顯示 SQLServer2012 為已註冊狀態,因此註冊作業成功。
查詢 VM 下所有未受保護的 SQL 資料庫
若要查詢儲存體帳戶中可保護的項目,請使用保護容器 - 查詢作業。 此為非同步作業,應該使用 location 標頭來追蹤結果。
POST https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{vaultName}/backupFabrics/{fabricName}/protectionContainers/{containerName}/inquire?api-version=2016-12-01$filter={$filter}
設定以上 URI 的變數,如下所示:
-
{resourceGroupName}:SQLServerSelfHost -
{vaultName}:SQLServer2012 -
{fabricName}:Azure -
{containerName}:指 GET ProtectableContainers 作業回應本文中的 name 屬性。 在我們的範例中,name 屬性是 VMAppContainer;Compute;SQLServerPMDemo;sqlserver-0。
POST https://management.azure.com/subscriptions/e3d2d341-4ddb-4c5d-9121-69b7e719485e/resourceGroups/SQLServerSelfHost/providers/microsoft.recoveryservices/vaults/SQLServer2012/backupFabrics/Azure/protectionContainers/VMAppContainer;Compute;SQLServerPMDemo;sqlserver-0/inquire?api-version=2016-12-01$filter=workloadType EQ 'SQLDatabase'
要求成功會傳回狀態碼 OK。
HTTP/1.1 202 Accepted
Pragma: no-cache
Retry-After: 60
X-Content-Type-Options: nosniff
x-ms-request-id: 50295ae9-3d5b-48d1-8a6d-a0acb6d06b98
x-ms-client-request-id: 4174f98a-80b9-4747-9500-6f702ed83930; 4174f98a-80b9-4747-9500-6f702ed83930
Strict-Transport-Security: max-age=31536000; includeSubDomains
x-ms-ratelimit-remaining-subscription-writes: 1197
x-ms-correlation-request-id: 50295ae9-3d5b-48d1-8a6d-a0acb6d06b98
x-ms-routing-request-id: SOUTHINDIA:20180528T084628Z:50295ae9-3d5b-48d1-8a6d-a0acb6d06b98
Cache-Control: no-cache
Date: Mon, 28 May 2018 08:46:28 GMT
Location: https://management.azure.com/subscriptions/00000000-0000-0000-0000-0000000000/resourceGroups/SQLServerSelfHost/providers/microsoft.recoveryservices/vaults/SQLServer2012/backupFabrics/Azure/protectionContainers/VMAppContainer;Compute;SQLServerPMDemo;sqlserver-0/operationResults/f0751ec2-445a-4d0e-a6a5-a19957459655?api-version=2016-12-01
X-Powered-By: ASP.NET
選取要備份的資料庫
若要列出訂閱下所有可保護的項目,並找出要備份的資料庫,請使用 GET backupprotectableItems 作業。
GET https://management.azure.com/Subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{vaultName}/backupProtectableItems?api-version=2016-12-01&$filter={$filter}
建構 URI,如下所述:
-
{resourceGroupName}:SQLServerSelfHost -
{vaultName}:SQLServer2012 -
{$filter}:backupManagementType eq 'AzureWorkload'
GET https://management.azure.com/subscriptions/00000000-0000-0000-0000-0000000000/resourceGroups/SQLServerSelfHost/providers/microsoft.recoveryservices/vaults/SQLServer2012/backupProtectableItems?api-version=2016-12-01&$filter=backupManagementType eq 'AzureWorkload'
範例回應:
Status Code:200
{
"value": [
{
"id": "/subscriptions/00000000-0000-0000-0000-0000000000/resourceGroups/SQLServerSelfHost/providers/microsoft.recoveryservices/vaults/SQLServer2012/backupFabrics/Azure/protectionContainers/vmappcontainer;compute;SQLServerSelfHost;SQLServersql2012/protectableItems/sqldatabase;mssqlserver;msdb",
"name": "sqldatabase;mssqlserver;msdb",
"type": "Microsoft.RecoveryServices/vaults/backupFabrics/protectionContainers/protectableItems",
"properties": {
"parentName": "MSSQLSERVER",
"serverName": "SQLServersql2012",
"isAutoProtectable": false,
"subinquireditemcount": 0,
"subprotectableitemcount": 0,
"backupManagementType": "AzureWorkload",
"workloadType": "SQL",
"protectableItemType": "SQLDataBase",
"friendlyName": "msdb",
"protectionState": "NotProtected"
}
}
]
}
回應包含所有未受保護資料庫的清單,還包含 Azure 復原服務設定備份所需的一切資訊。 儲存資料庫名稱以供日後使用。
對資料庫啟用備份
以自訂名稱識別相關資料庫之後:
- 選取要保護的原則。
- 列出保存庫中的現有原則,請參閱列出原則 API。
- 參考原則名稱來選取相關原則。
- 建立原則教學課程。
啟用保護為非同步 PUT 作業,將會建立受保護的項目。
PUT https://management.azure.com/subscriptions/00000000-0000-0000-0000-0000000000/resourceGroups/SQLServerSelfHost/providers/microsoft.recoveryservices/vaults/SQLServer2012/backupFabrics/Azure/protectionContainers/{containerName};sqlserver-0/protectedItems/{protectedItemName}?api-version=2016-12-01
在 GET backupprotectableitems 作業的回應本文中,使用 ID 屬性來設定 containerName 和 protectedItemName 變數。
在我們的範例中,需受保護檔案共用的識別碼為:
/subscriptions/00000000-0000-0000-0000-0000000000/resourceGroups/SQLServerSelfHost/providers/microsoft.recoveryservices/vaults/SQLServer2012/backupFabrics/Azure/protectionContainers/VMAppContainer;Compute;SQLServerPMDemo;sqlserver-0/protectedItems/sqldatabase;mssqlserver;msdb
-
{containerName}:VMAppContainer;Compute;SQLServerPMDemo;sqlserver-0 -
{protectedItemName}:sqldatabase;mssqlserver;msdb
建立要求本文:
下列要求本文會定義建立受保護的項目所需的屬性。
{
"properties": {
"backupManagementType": "AzureWorkload",
"workloadType": "SQLDataBase",
"policyId": "/subscriptions/00000000-0000-0000-0000-0000000000/resourceGroups/SQLServerSelfHost/providers/microsoft.recoveryservices/vaults/SQLServer2012/backupPolicies/HourlyLogBackup"
},
"location": "westcentralus"
}
提交 PUT 要求以建立或更新受保護的項目之後,初始回應為 202 (已接受) 且附帶 location 標頭。
範例回覆
建立受保護的項目為非同步作業,將會建立另一個需要追蹤的作業。 該作業傳回兩個回應:在建立另一項作業時傳回 202 (已接受),並在該作業完成時傳回 200 (OK)。
提交 PUT 要求以建立或更新受保護的項目之後,初始回應為 202 (已接受) 且附帶 location 標頭。
HTTP/1.1 202 Accepted
Pragma: no-cache
Retry-After: 60
Azure-AsyncOperation: https://management.azure.com/subscriptions/00000000-0000-0000-0000-0000000000/resourceGroups/SQLServerSelfHost/providers/microsoft.recoveryservices/vaults/SQLServer2012/backupFabrics/Azure/protectionContainers/VMAppContainer;Compute;SQLServerPMDemo;sqlserver-0/protectedItems/sqldatabase;mssqlserver;msdb/operationsStatus/b686a165-387f-461d-8579-c55338566338?api-version=2016-12-01
X-Content-Type-Options: nosniff
x-ms-request-id: ab6a8c6c-ab90-433a-8dc2-5194901d428d
x-ms-client-request-id: 7d03bcef-562a-4ddc-8086-a3f4981be915; 7d03bcef-562a-4ddc-8086-a3f4981be915
Strict-Transport-Security: max-age=31536000; includeSubDomains
x-ms-ratelimit-remaining-subscription-writes: 1199
x-ms-correlation-request-id: ab6a8c6c-ab90-433a-8dc2-5194901d428d
x-ms-routing-request-id: SOUTHINDIA:20180528T102112Z:ab6a8c6c-ab90-433a-8dc2-5194901d428d
Cache-Control: no-cache
Date: Mon, 28 May 2018 10:21:12 GMT
Location: https://management.azure.com/subscriptions/00000000-0000-0000-0000-0000000000/resourceGroups/SQLServerSelfHost/providers/microsoft.recoveryservices/vaults/SQLServer2012/backupFabrics/Azure/protectionContainers/VMAppContainer;Compute;SQLServerPMDemo;sqlserver-0/protectedItems/sqldatabase;mssqlserver;msdb/operationResults/b686a165-387f-461d-8579-c55338566338?api-version=2016-12-01
X-Powered-By: ASP.NET
然後,透過 GET 命令,使用 location 標頭或 Azure-AsyncOperation 標頭來追蹤產生的作業。
GET https://management.azure.com/subscriptions/00000000-0000-0000-0000-0000000000/resourceGroups/SQLServerSelfHost/providers/microsoft.recoveryservices/vaults/SQLServer2012/backupFabrics/Azure/protectionContainers/VMAppContainer;Compute;SQLServerPMDemo;sqlserver-0/protectedItems/sqldatabase;mssqlserver;msdb/operationResults/b686a165-387f-461d-8579-c55338566338?api-version=2016-12-01
作業完成之後,回應本文中會傳回 200 (OK) 及受保護的項目內容。
範例回應本文:
{
"id": "/subscriptions/00000000-0000-0000-0000-0000000000/resourceGroups/SQLServerSelfHost/providers/microsoft.recoveryservices/vaults/SQLServer2012/backupFabrics/Azure/protectionContainers/VMAppContainer;Compute;SQLServerPMDemo;sqlserver-0/protectedItems/SQLDataBase;mssqlserver;msdb",
"name": "SQLDataBase;mssqlserver;msdb",
"type": "Microsoft.RecoveryServices/vaults/backupFabrics/protectionContainers/protectedItems",
"properties": {
"friendlyName": "msdb",
"serverName": "sqlserver-0.shopkart.com",
"parentName": "MSSQLSERVER",
"parentType": "AzureVmWorkloadSQLInstance",
"protectionStatus": "Healthy",
"protectionState": "IRPending",
"lastBackupStatus": "IRPending",
"lastBackupErrorDetail": {
"code": "Success",
"message": ""
},
"protectedItemDataSourceId": "17592741727863",
"protectedItemHealthStatus": "IRPending",
"extendedInfo": {
"recoveryPointCount": 0,
"policyState": "Consistent"
},
"protectedItemType": "AzureVmWorkloadSQLDatabase",
"backupManagementType": "AzureWorkload",
"workloadType": "SQLDataBase",
"containerName": "VMAppContainer;Compute;SQLServerPMDemo;sqlserver-0",
"sourceResourceId": "/subscriptions/00000000-0000-0000-0000-0000000000/resourceGroups/SQLServerPMDemo/providers/VMAppContainer/sqlserver-0",
"policyId": "/subscriptions/00000000-0000-0000-0000-0000000000/resourceGroups/SQLServerSelfHost/providers/microsoft.recoveryservices/vaults/SQLServer2012/backupPolicies/HourlyLogBackup"
}
}
這確認資料庫已啟用保護,且會根據原則排程來觸發第一次備份。
觸發資料庫的隨選備份
設定要備份的資料庫之後,就會根據原則排程來執行備份。 您可以等候第一個排定的備份,或隨時觸發隨選備份。
觸發隨選備份為 POST 作業。
注意
此備份的保留期間取決於您執行的隨選備份類型。
- 「隨選完整」備份至少會保留「45 天」,最多保留「99 年」。
- 「隨選僅複製完整」備份可接受任何保留期間值。
- 「隨選差異」備份會按照原則中所設的排程差異來保留備份。
- 「隨選記錄」備份會按照原則中所設的排程記錄保留期來保留備份。
POST https://management.azure.com/Subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{vaultName}/backupFabrics/{fabricName}/protectionContainers/{containerName}/protectedItems/{protectedItemName}/backup?api-version=2016-12-01
啟用備份時,{containerName} 和 {protectedItemName} 建構如上。 針對我們的範例,這會轉譯為:
POST https://management.azure.com/subscriptions/00000000-0000-0000-0000-0000000000/resourceGroups/SQLServerSelfHost/providers/Microsoft.RecoveryServices/vaults/SQLServer2012/backupFabrics/Azure/protectionContainers/VMAppContainer;Compute;SQLServerPMDemo;sqlserver-0/protectedItems/sqldatabase;mssqlserver;msdb/backup?api-version=2016-12-01
建立要求本文
請使用下列要求本文來建立隨選完整備份。
{
"properties": {
"objectType": "AzureWorkloadBackupRequest",
"backupType": "Full"
}
}
隨選備份作業的回應
觸發隨選備份為非同步作業。 這表示此作業會建立另一項需要個別追蹤的作業。
此作業傳回兩個回應:建立另一項作業時傳回 202 (已接受),該作業完成時傳回 200 (OK)。
隨選備份作業的回應範例
一旦提交 POST 要求以進行隨選備份之後,初始回應會是 202 (已接受) 並具備位置標頭或 Azure-async-header。
HTTP/1.1 202 Accepted
Pragma: no-cache
Retry-After: 60
Azure-AsyncOperation: https://management.azure.com/subscriptions/00000000-0000-0000-0000-0000000000/resourceGroups/SQLServerSelfHost/providers/microsoft.recoveryservices/vaults/SQLServer2012/backupFabrics/Azure/protectionContainers/VMAppContainer;Compute;SQLServerPMDemo;sqlserver-0/protectedItems/sqldatabase;mssqlserver;msdb/operationsStatus/cd2a3b13-d392-4e81-86ac-02ea91cc70b9?api-version=2016-12-01
X-Content-Type-Options: nosniff
x-ms-request-id: a691e2a9-8203-462d-a4da-d1badde22f83
x-ms-client-request-id: 6b033cf6-f875-4c03-8985-9add07ec2845; 6b033cf6-f875-4c03-8985-9add07ec2845
Strict-Transport-Security: max-age=31536000; includeSubDomains
x-ms-ratelimit-remaining-subscription-writes: 1199
x-ms-correlation-request-id: a691e2a9-8203-462d-a4da-d1badde22f83
x-ms-routing-request-id: SOUTHINDIA:20180528T114321Z:a691e2a9-8203-462d-a4da-d1badde22f83
Cache-Control: no-cache
Date: Mon, 28 May 2018 11:43:21 GMT
Location: https://management.azure.com/subscriptions/00000000-0000-0000-0000-0000000000/resourceGroups/SQLServerSelfHost/providers/microsoft.recoveryservices/vaults/SQLServer2012/backupFabrics/Azure/protectionContainers/VMAppContainer;Compute;SQLServerPMDemo;sqlserver-0/protectedItems/sqldatabase;mssqlserver;msdb/operationResults/cd2a3b13-d392-4e81-86ac-02ea91cc70b9?api-version=2016-12-01
X-Powered-By: ASP.NET
然後,透過 GET 命令,使用 location 標頭或 Azure-AsyncOperation 標頭來追蹤產生的作業。
GET https://management.azure.com/subscriptions/00000000-0000-0000-0000-0000000000/resourceGroups/SQLServerSelfHost/providers/microsoft.recoveryservices/vaults/SQLServer2012/backupFabrics/Azure/protectionContainers/VMAppContainer;Compute;SQLServerPMDemo;sqlserver-0/protectedItems/sqldatabase;mssqlserver;msdb/operationsStatus/cd2a3b13-d392-4e81-86ac-02ea91cc70b9?api-version=2016-12-01
作業完成之後,回應本文中會傳回 200 (OK),並附帶所產生備份工作的識別碼。
樣本回應本文
{
"id": "cd2a3b13-d392-4e81-86ac-02ea91cc70b9",
"name": "cd2a3b13-d392-4e81-86ac-02ea91cc70b9",
"status": "Succeeded",
"startTime": "2018-05-28T11:43:21.6516182Z",
"endTime": "2018-05-28T11:43:21.6516182Z",
"properties": {
"objectType": "OperationStatusJobExtendedInfo",
"jobId": "c22eca5d-0c1c-48a0-a40d-69bef708d92a"
}
}
備份工作是長時間執行的作業,需要追蹤,如使用 REST API 監視工作文件所述。
下一步
- 使用 REST API 還原 SQL 資料庫。
- 使用 Azure 入口網站、 Azure CLI、 REST API 管理 Azure VM 中的 SQL Server 資料庫。