Skip to main content

Lab 025: Backup an Azure SQL Database



Requirements

  1. An Azure SQL Database instance named xfusion-db is already running in the East US region.

  2. Take a backup of this SQL database and store it in the storage account xfusionstorage9846 under the blob container xfusion-container-16194.

  3. The backup file must be named xfusion-db-backup.

  4. Download the backup file to the /opt directory on the azure-client host.

  5. The password for the SQL database xfusion-db is Damin@123.

  6. Ensure the backup file is fully exported to the blob container before proceeding to download it.

Note: By default, whatever file extension you find in the container, just use the same file name to download it to the client host.


Note

This page preserves the original requirement text and documents one CLI-based export and download workflow.

Prerequisites

  • Azure CLI is installed and authenticated on azure-client.
  • Required credentials are available from showcreds.
  • You can access the SQL server and storage account in the target resource group.

Steps

For the Azure credentials, enter showcreds command. For further details, check out the Project Nautilus documentation.

# Get the azure regource group info with the below azure cli command
az group list
#resource group: kml_rg_main-043788b7c2e7454e

Command to update Rule to enable public access endpoint for Azure SQL server

az sql server firewall-rule create \
--resource-group kml_rg_main-043788b7c2e7454e \
--server xfusion-server-17732 \
--name AllowAllAzureServices \
--start-ip-address 0.0.0.0 \
--end-ip-address 0.0.0.0

Take SQL DB Backup using Azure CLI and upload the backup to the Azure blob storage container

az sql db export \
--admin-user xfusion-admin \
--admin-password Damin@123 \
--name xfusion-db \
--server xfusion-server-17732 \
--resource-group kml_rg_main-043788b7c2e7454e \
--storage-key-type StorageAccessKey \
--storage-key $(az storage account keys list --account-name xfusionstorage9846 --resource-group kml_rg_main-043788b7c2e7454e --query [0].value -o tsv) \
--storage-uri https://xfusionstorage9846.blob.core.windows.net/xfusion-container-16194/xfusion-db-backup.bacpac

Now download the backup to the location /opt in the azure-client

az storage blob download \
--container-name xfusion-container-16194 \
--account-name xfusionstorage9846 \
--name xfusion-db-backup.bacpac \
--file /opt/xfusion-db-backup.bacpac

Verify the file downloaded at location /opt

ls -lh /opt/xfusion-db-backup.bacpac

Verification

  • Confirm export completed successfully in the target blob container.
  • Confirm file xfusion-db-backup.bacpac exists on azure-client under /opt.
az storage blob show \
--container-name xfusion-container-16194 \
--account-name xfusionstorage9846 \
--name xfusion-db-backup.bacpac \
--output table

ls -lh /opt/xfusion-db-backup.bacpac

Resources