Az cli backups
Jump to navigation
Jump to search
az disk grant-access --duration-in-seconds 86400 --access-level Read --name azd0-foo_OsDisk_1 --resource-group MY-RESOURCE-GROUP
Download
az login --scope https://management.core.windows.net//.default url="https://md-hdd-..myurlfrom-grant-access" file_name=azd0-foo.vhd az storage blob download -f ${file_name} --blob-url ${url}
Backup disks via array in MY-RGRP resource group
#!/bin/bash set -eux rg_name=MY-RGRP ttl=43200 ttl=86400 disks=( azd0-foo_osdisk01 azd0-foo_datadisk01 ) jq -h || sudo apt install -y jq main(){ for disk_name in "${disks[@]}"; do file_name="${disk_name}__${rg_name}.vhd" echo Exporting disk $file_name in 10 seconds; sleep 10 r=$(az disk grant-access --duration-in-seconds $ttl --access-level Read --name $disk_name --resource-group $rg_name) url=$(echo $r | jq -r '.accessSas') echo Downloading disk vhd for $file_name from $url in 10 seconds; sleep 10 echo Downloading now az storage blob download -f ${file_name} --blob-url ${url} tar -czvf ${file_name}.tgz ${file_name} rm ${file_name} done } main