Difference between revisions of "Az cli backups"
Jump to navigation
Jump to search
Line 9: | Line 9: | ||
file_name=azd0-foo.vhd | file_name=azd0-foo.vhd | ||
az storage blob download -f ${file_name} --blob-url ${url} | az storage blob download -f ${file_name} --blob-url ${url} | ||
+ | ``` | ||
+ | |||
+ | |||
+ | Backup disks via array in MY-RGRP resource group | ||
+ | ``` | ||
+ | #!/bin/bash | ||
+ | set -eu | ||
+ | rg_name=MY-RGRP | ||
+ | ttl=43200 | ||
+ | ttl=86400 | ||
+ | |||
+ | disks=( | ||
+ | azd0-foo_osdisk01 | ||
+ | azd0-foo_datadisk01 | ||
+ | ) | ||
+ | |||
+ | main(){ | ||
+ | for disk_name in "${disks[@]}"; do | ||
+ | file_name="${disk_name}__${rg_name}}" | ||
+ | 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 '.accessSas') | ||
+ | echo Downloading disk vhd for $file_name from $url in 10 seconds; sleep 10 | ||
+ | az storage blob download -f ${file_name} --blob-url ${url} | ||
+ | done | ||
+ | } | ||
``` | ``` |
Revision as of 18:43, 14 September 2022
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 -eu rg_name=MY-RGRP ttl=43200 ttl=86400 disks=( azd0-foo_osdisk01 azd0-foo_datadisk01 ) main(){ for disk_name in "${disks[@]}"; do file_name="${disk_name}__${rg_name}}" 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 '.accessSas') echo Downloading disk vhd for $file_name from $url in 10 seconds; sleep 10 az storage blob download -f ${file_name} --blob-url ${url} done }