Tutorial: Manage SAP HANA databases in an Azure VM using Azure CLI
Article
Azure CLI is used to create and manage Azure resources from the Command Line or through scripts. This documentation details how to manage a backed-up SAP HANA database on Azure VM - all using Azure CLI. You can also perform these steps using the Azure portal.
protected container named VMAppContainer;Compute;saphanaResourceGroup;saphanaVM
backed-up database/item named saphanadatabase;hxe;hxe
resources in the westus2 region
Azure CLI makes it easy to manage an SAP HANA database running on an Azure VM that's backed-up using Azure Backup. This tutorial details each of the management operations.
az backup job list --resource-group saphanaResourceGroup \
--vault-name saphanaVault \
--output table
The output will look something like this:
Output
Name Operation Status Item Name Start Time UTC
------------------------------------ --------------- --------- ---------- -------------------
e0f15dae-7cac-4475-a833-f52c50e5b6c3 ConfigureBackup Completed hxe 2019-12-03T03:09:210831+00:00
ccdb4dce-8b15-47c5-8c46-b0985352238f Backup (Full) Completed hxe [hxehost] 2019-12-01T10:30:58.867489+00:00
4980af91-1090-49a6-ab96-13bc905a5282 Backup (Differential) Completed hxe [hxehost] 2019-12-01T10:36:00.563909+00:00
F7c68818-039f-4a0f-8d73-e0747e68a813 Restore (Log) Completed hxe [hxehost] 2019-12-03T05:44:51.081607+00:00
Change policy
To change the policy underlying the SAP HANA backup configuration, use the az backup policy set cmdlet. The name parameter in this cmdlet refers to the backup item whose policy we want to change. For this tutorial, we'll be replacing the policy of our SAP HANA database saphanadatabase;hxe;hxe with a new policy newsaphanaPolicy. New policies can be created using the az backup policy create cmdlet.
Azure CLI
az backup item set policy --resource-group saphanaResourceGroup \
--vault-name saphanaVault \
--container-name VMAppContainer;Compute;saphanaResourceGroup;saphanaVM \
--policy-name newsaphanaPolicy \
--name saphanadatabase;hxe;hxe \
The output should look like this:
Output
Name Resource Group
------------------------------------- --------------
cb110094-9b15-4c55-ad45-6899200eb8dd SAPHANA
Create incremental backup policy
To create an incremental backup policy, execute the az backup policy create command with the following parameters:
--backup-management-type – Azure Workload
--workload-type - SAPHana
--name – Name of the policy
--policy - JSON file with appropriate details for schedule and retention
Once the policy is created successfully, the output of the command will display the policy JSON that you passed as a parameter while executing the command.
You can modify the following section of the policy to specify the desired backup frequency and retention for incremental backups.
However, in cases when new databases are added to the SAP HANA instance later, use the az backup protectable-item initialize cmdlet. This cmdlet discovers the new databases added.
Then use the az backup protectable-item list cmdlet to list all the databases that have been discovered on your SAP HANA instance. This list, however, excludes those databases on which backup has already been configured. Once the database to be backed-up is discovered, refer to Enable backup on SAP HANA database.
Azure CLI
az backup protectable-item list --resource-group saphanaResourceGroup \
--vault-name saphanaVault \
--workload-type SAPHANA \
--output table
The new database that you want to back up will show up in this list, which will look as follows:
Name ResourceGroup
------------------------------------ ---------------
g0f15dae-7cac-4475-d833-f52c50e5b6c3 saphanaResourceGroup
To check the status of this operation, use the az backup job show cmdlet.
Resume protection
When you stop protection for the SAP HANA database with retain data, you can later resume protection. If you don't retain the backed-up data, you won't be able to resume protection.