Catatan
Akses ke halaman ini memerlukan otorisasi. Anda dapat mencoba masuk atau mengubah direktori.
Akses ke halaman ini memerlukan otorisasi. Anda dapat mencoba mengubah direktori.
Artikel ini menjelaskan cara mencadangkan database server SQL di Azure VM menggunakan Azure Backup melalui REST API.
Nota
Lihat matriks dukungan cadangan SQL untuk mengetahui selengkapnya tentang konfigurasi dan skenario yang didukung.
Prasyarat
- Gudang Layanan Pemulihan
- Kebijakan untuk mengonfigurasi cadangan untuk database SQL Anda.
Untuk informasi selengkapnya tentang cara membuat vault dan kebijakan baru, lihat tutorial REST API buat vault dan buat kebijakan.
Gunakan sumber daya berikut:
- Layanan Pemulihan Vault: SQLServer2012
- Kebijakan: HourlyLogBackup
- Grup sumber daya: SQLServerSelfHost
Mengonfigurasi cadangan untuk database server SQL yang tidak terlindungi di Azure VM
Menemukan database SQL Server yang tidak terlindungi
Vault perlu menemukan semua Azure VM dalam langganan dengan database SQL yang dapat Anda cadangkan ke vault Layanan Pemulihan. Untuk mengambil detailnya, picu operasi refresh. Ini adalah operasi POST asinkron yang memastikan vault menerima daftar terbaru dari semua database SQL yang tidak terlindungi dalam langganan saat ini dan menyimpannya di cache . Setelah database di-cache, layanan pemulihan dapat mengakses database dan melindunginya.
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 memiliki {subscriptionId}parameter , {vaultName}, {vaultresourceGroupName}, dan {fabricName} . Dalam contoh berikut, nilai untuk parameter yang berbeda adalah sebagai berikut:
-
{fabricName}: Azure -
{vaultName}: SQLServer2012 -
{vaultresourceGroupName}: SQLServerSelfHost -
$filter: backupManagementType eq 'AzureWorkload'
Karena semua parameter yang diperlukan diberikan dalam URI3, isi permintaan terpisah tidak diperlukan.
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'
Tanggapan terhadap operasi penyegaran
Operasi refresh adalah operasi asinkron. Hal ini berarti operasi tersebut menciptakan operasi lain yang perlu dilacak secara terpisah.
Ini mengembalikan dua respons: 202 (Diterima) ketika operasi lain dibuat, dan 200 (OK) ketika operasi tersebut selesai.
Contoh respons untuk operasi penyegaran
Setelah Anda mengirimkan permintaan POST , respons 202 (Diterima) dikembalikan.
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
Lacak operasi yang dihasilkan menggunakan header Lokasi dengan perintah GET sederhana.
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
Setelah semua database SQL ditemukan, perintah GET mengembalikan respons 200 (Tanpa Konten). Vault sekarang dapat menemukan dan mengidentifikasi VM apa pun dengan database SQL yang dapat dilakukan pencadangan dalam langganan.
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
Daftar VM dengan database SQL untuk dicadangkan menggunakan vault Recovery Services
Untuk mengonfirmasi bahwa caching selesai, cantumkan semua VM dalam langganan dengan SQL database yang dapat di-backup dengan Layanan Pemulihan vault. Kemudian temukan akun penyimpanan yang diinginkan dalam respons. Ini dilakukan menggunakan operasi 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'
Nota
URI GET memiliki semua parameter yang diperlukan. Tidak diperlukan isi permintaan tambahan.
Contoh isi respons:
{
"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"
}
}
]
}
Karena kita dapat menemukan VM dalam isi respons dengan nama yang mudah dipahami, operasi refresh yang telah dilakukan sebelumnya berhasil. Brankas Layanan Pemulihan sekarang dapat menemukan VM dengan database SQL yang tidak terlindungi dalam langganan yang sama.
Mendaftarkan VM dengan brankas Layanan Pemulihan
Anda perlu mendaftarkan VM dengan vault Layanan Pemulihan sehingga layanan Azure Backup dapat berinteraksi dengan database SQL dalam VM (gunakan nilai di bidang Nama untuk mengidentifikasi kontainer Azure VM). Anda perlu menyediakan nilai dalam permintaan JSON untuk mendapatkan isi permintaan HTTP dari kumpulan properti dari hasil daftar kontainer yang dapat dilindungi.
PUT https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.recoveryservices/vaults/{vaultName}/backupFabrics/Azure/protectionContainers/{containerName}?api-version=2016-12-01
Atur variabel untuk URI sebagai berikut:
-
{resourceGroupName}- SQLServerSelfHost -
{fabricName}- Azure -
{vaultName}- SQLServer2012 -
{containerName}- Ini adalah atribut nama dalam isi respons operasi GET ProtectableContainers . Dalam contoh kami, nama atributnya adalah VMAppContainer; Menghitung; SQLServerPMDemo; sqlserver-0.
Nota
Selalu ambil atribut nama dari respons dan isi ke dalam permintaan ini. Jangan menggunakan hard-code atau membuat format nama kontainer. Jika Anda membuat atau menetapkan secara permanen, panggilan API pasti akan gagal jika format nama kontainer berubah di masa mendatang.
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
Isi permintaan pembuatan adalah sebagai berikut:
{
"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"
}
}
Untuk daftar lengkap definisi isi permintaan dan detail lainnya, lihat ProtectionContainers-Register.
Ini adalah operasi asinkron dan mengembalikan dua respons: 202 (Diterima) ketika operasi diterima, dan 200 (OK) ketika operasi selesai. Untuk melacak status fungsi, gunakan header lokasi untuk mendapatkan status fungsi terbaru.
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
Contoh isi respons saat fungsi selesai:
{
"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"
}
}
Anda dapat memverifikasi apakah pendaftaran berhasil dari nilai parameter registrationstatus di isi respons. Dalam kasus kami, ini menunjukkan status sebagai terdaftar untuk SQLServer2012; jadi, operasi pendaftaran berhasil.
Tanyakan semua database SQL yang tidak terlindungi di bawah VM
Untuk menanyakan tentang item yang dapat dilindungi di akun penyimpanan, gunakan operasi Perlindungan Kontainer-Inquire . Ini adalah fungsi asinkron dan hasilnya harus dilacak menggunakan header lokasi.
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}
Atur variabel URI sebagai berikut:
-
{resourceGroupName}: SQLServerSelfHost -
{vaultName}: SQLServer2012 -
{fabricName}: Azure -
{containerName}: Lihat atribut nama dalam isi respons operasi GET ProtectableContainers. Dalam contoh kami, nama atributnya adalah VMAppContainer; Menghitung; 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'
Setelah permintaan berhasil, permintaan mengembalikan kode status 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
Pilih database yang ingin Anda cadangkan
Untuk mencantumkan semua item yang dapat dilindungi di bawah langganan dan menemukan database yang diinginkan untuk dicadangkan, gunakan operasi GET backupprotectableItems .
GET https://management.azure.com/Subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{vaultName}/backupProtectableItems?api-version=2016-12-01&$filter={$filter}
Susun URI sebagai berikut:
-
{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'
Contoh respons:
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"
}
}
]
}
Respons berisi daftar semua database yang tidak terlindungi dan berisi semua informasi yang diperlukan oleh Azure Recovery Service untuk mengonfigurasi cadangan. Simpan nama database untuk digunakan di masa mendatang.
Mengaktifkan pencadangan untuk basis data
Setelah database yang relevan diidentifikasi dengan nama yang mudah diingat:
- Pilih kebijakan yang akan dilindungi.
- Daftar kebijakan yang ada di vault, lihat dengan API daftar kebijakan.
- Pilih kebijakan yang relevan dengan merujuk ke nama kebijakan.
- Buat tutorial kebijakan.
Mengaktifkan perlindungan adalah operasi PUT asinkron yang membuat item yang dilindungi.
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
Atur variabel containerName dan protectedItemName menggunakan atribut ID di isi respons operasi GET backupprotectableitems .
Dalam contoh kami, ID berbagi file yang ingin kami lindungi adalah:
/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
Membuat isi permintaan:
Isi permintaan berikut menentukan properti yang diperlukan untuk membuat item terproteksi.
{
"properties": {
"backupManagementType": "AzureWorkload",
"workloadType": "SQLDataBase",
"policyId": "/subscriptions/00000000-0000-0000-0000-0000000000/resourceGroups/SQLServerSelfHost/providers/microsoft.recoveryservices/vaults/SQLServer2012/backupPolicies/HourlyLogBackup"
},
"location": "westcentralus"
}
Setelah Anda mengirimkan permintaan PUT untuk pembuatan atau pembaruan item terproteksi, respons awalnya adalah 202 (Diterima) dengan header lokasi.
Contoh tanggapan
Pembuatan item yang diproteksi adalah fungsi asinkron, yang menciptakan fungsi lain yang perlu dilacak. Ini mengembalikan dua respons: 202 (Diterima) ketika operasi lain dibuat, dan 200 (OK) ketika operasi tersebut selesai.
Setelah Anda mengirimkan permintaan PUT untuk pembuatan atau pembaruan item terproteksi, respons awalnya adalah 202 (Diterima) dengan header lokasi.
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
Kemudian lacak hasil operasi menggunakan header lokasi atau header Azure-AsyncOperation dengan perintah DAPATKAN.
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
Setelah operasi selesai, operasi mengembalikan 200 (OK) dengan konten item yang dilindungi dalam isi respons.
Isi Respons Sampel:
{
"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"
}
}
Ini mengonfirmasi bahwa perlindungan diaktifkan untuk database, dan cadangan pertama akan dipicu sesuai dengan jadwal kebijakan.
Memicu cadangan sesuai permintaan untuk database
Setelah Anda mengonfigurasi database untuk pencadangan, pencadangan berjalan sesuai dengan jadwal kebijakan. Anda dapat menunggu cadangan terjadwal pertama atau memulai pencadangan sesuai permintaan kapan saja.
Memicu pencadangan sesuai permintaan merupakan operasi POST.
Nota
Periode retensi pencadangan ini ditentukan oleh jenis pencadangan on-demand yang telah Anda jalankan.
- Penuh sesuai permintaan mempertahankan cadangan selama minimal 45 hari dan maksimum 99 tahun.
- Salinan penuh sesuai permintaan menerima nilai berapa pun untuk retensi.
- Diferensial sesuai permintaan mempertahankan cadangan sesuai dengan retensi diferensial yang dijadwalkan dalam kebijakan.
- Log sesuai permintaan mempertahankan cadangan sesuai retensi log terjadwal yang ditetapkan dalam kebijakan.
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} dan {protectedItemName} seperti yang tersusun di atas sambil mengaktifkan pencadangan. Untuk contoh yang kami berikan, hal ini diterjemahkan menjadi:
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
Buat isi permintaan
Gunakan isi permintaan berikut untuk membuat cadangan penuh sesuai permintaan.
{
"properties": {
"objectType": "AzureWorkloadBackupRequest",
"backupType": "Full"
}
}
Tanggapan terhadap operasi pencadangan berdasarkan permintaan
Memicu cadangan sesuai permintaan adalah operasi asinkron. Hal ini berarti operasi tersebut menciptakan operasi lain yang perlu dilacak secara terpisah.
Ini mengembalikan dua respons: 202 (Diterima) ketika operasi lain dibuat dan 200 (OK) ketika operasi tersebut selesai.
Contoh respons untuk operasi pencadangan sesuai permintaan
Setelah Anda mengirimkan permintaan POST untuk cadangan sesuai permintaan, respons awalnya adalah 202 (Diterima) dengan header lokasi atau 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
Kemudian lacak hasil operasi menggunakan header lokasi atau header Azure-AsyncOperation dengan perintah DAPATKAN.
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
Setelah operasi selesai, operasi mengembalikan 200 (OK) dengan ID pekerjaan pencadangan yang dihasilkan dalam isi respons.
Contoh isi respons
{
"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"
}
}
Karena tugas pencadangan adalah operasi jangka panjang, tugas tersebut perlu dilacak seperti yang dijelaskan dalam dokumen REST API tentang memantau pekerjaan.
Langkah selanjutnya
- Pulihkan database SQL menggunakan REST API.
- Mengelola database server SQL di Azure VM dengan portal Microsoft Azure, Azure CLI, REST API.