Credits: Kartik Pullabhota (Sr. PM for Automation, HANA and Database backup using Azure Backup) for SME input and Swathi Dhanwada (Customer Engineer, Tech community) for testing.
Prerequisites
If you don't already have an Azure subscription, create a free account before you begin.
Azure CLI:
Note: Support for Azure Blobs back up and restore via CLI is in preview and available as an extension in Az 2.15.0 version and later. The extension is automatically installed when you run the az dataprotection commands. Learn more about extensions.
Create resource group:
RGNAME= ‘your resource group name’
LOCATION= ‘your location’
az group create --name $RGNAME --location $LOCATION
az group show --name $RGNAME
Create storage account
Create storage container
az storage container create \
--account-name <storage-account> \
--name <container> \
--auth-mode login
Create a sample file (blob) and upload to container
az role assignment create \
--role "Storage Blob Data Contributor" \
--assignee ”object-id” \
--scope "/subscriptions/<subscription>/resourceGroups/<resource-group>/providers/Microsoft.Storage/storageAccounts/<storage-account>"
Note: To retrieve objectid of signed in user, run the following command.
az ad signed-in-user show --query objectId -o tsv
vi helloworld
az storage blob upload \
--account-name <storage-account> \
--container-name <container> \
--name helloworld \
--file helloworld \
--auth-mode login
az storage blob list \
--account-name <storage-account>\
--container-name <container> \
--output table \
--auth-mode login
Create backup vault
az dataprotection backup-vault create -g <rgname> --vault-name <backupvaultname> -l westus --type SystemAssigned --storage-settings datastore-type="VaultStore" type="LocallyRedundant"
Create backup policy for azure blob
az dataprotection backup-policy get-default-policy-template --datasource-type AzureBlob > BlobPolicy.json
az dataprotection backup-policy create -g <rgname> --vault-name <backupvaultname> -n mypolicy --policy BlobPolicy.json
Grant required permissions to backup vault
Configure backup for azure blob
az dataprotection backup-instance initialize --datasource-type AzureBlob -l southeastasia --policy-id "subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/<rgname>/providers/Microsoft.DataProtection/backupVaults/<backupvaultname>/backupPolicies/BlobBackup-Policy" --datasource-id "/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx/resourcegroups/blobrg/providers/Microsoft.Storage/storageAccounts/CLITestSA" > backup_instance.json
az dataprotection backup-instance create –g <rgname> --vault-name <backupvaultname> --backup-instance backup_instance.json
Restore Azure Blobs within a storage account
az dataprotection backup-instance list --resource-group <rgname> --vault-name <backupvaultname>
az dataprotection backup-instance show --resource-group <rgname> --vault-name <backupvaultname> --name <backup-instance-name obtained from previous step>
Initialize Restore operation
az dataprotection restorable-time-range find --start-time 2021-05-30T00:00:00 --end-time 2021-05-31T00:00:00 --source-data-store-type OperationalStore -g <rgname> --vault-name <backupvaultname> --backup-instances <backup instance id retrieved from previous step>
az dataprotection backup-instance restore initialize-for-data-recovery --datasource-type AzureBlob --restore-location southeastasia --source-datastore OperationalStore --target-resource-id "/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx/resourcegroups/<rgname>/providers/Microsoft.Storage/storageAccounts/<storage-account-name>" --point-in-time 2021-06-02T18:53:44.4465407Z > restore.json
az dataprotection backup-instance restore initialize-for-item-recovery --datasource-type AzureBlob --restore-location southeastasia --source-datastore OperationalStore --backup-instance-id "/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxx/resourceGroups/<rgname>/providers/Microsoft.DataProtection/backupVaults/<backupvaultname>/backupInstances/ <backup instance id retrieved from previous step>" --point-in-time 2021-06-02T18:53:44.4465407Z --container-list container1 container2 > restore.json
az dataprotection backup-instance restore initialize-for-item-recovery --datasource-type AzureBlob --restore-location southeastasia --source-datastore OperationalStore --backup-instance-id "/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxx/resourceGroups/<rgname>/providers/Microsoft.DataProtection/backupVaults/<backupvaultname>/backupInstances/ <backup instance id retrieved from previous step>" --point-in-time 2021-06-02T18:53:44.4465407Z --from-prefix-pattern container1/text1 container2/text4 --to-prefix-pattern container1/text4 container2/text41 > restore.json
Note: The time zone for point-in-time will be taken as UTC
Trigger the restore
Below command triggers the restore operation
az dataprotection backup-instance restore trigger -g <rgname> --vault-name <backupvaultname> --backup-instances <backup instance id retrieved from previous step> --restore-request-object restore.json
Track backup jobs
az dataprotection job list-from-resourcegraph --datasource-type AzureBlob --operation Restore
Additional Resources
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.