Azure Backup automatically takes a pre-restore backup only when performing a direct VM restore. To bypass this step, you should use the restore-disks method instead, which allows you to restore the VM's disks without triggering a backup.
How to Skip Pre-Restore Backup via Azure CLI?
Hi,
When I use the Azure Portal to restore VMs, I see an option to skip the pre-restore backup, but I don’t see a similar option available when using the Azure CLI. Can someone help clarify how I can achieve this in the CLI? https://learn.microsoft.com/en-us/cli/azure/backup/restore?view=azure-cli-latest#az-backup-restore-restore-disks
Here’s the snippet of the script I’m currently using to restore VMs:
for SERVER in "${SERVER_LIST[@]}"; do
echo "Processing $SERVER..."
# Get the latest restore point for the given date
LATEST_RESTORE_POINT=$(az backup recoverypoint list \
--resource-group "$RESOURCE_GROUP" \
--vault-name "$RECOVERY_VAULT" \
--container-name "$SERVER" \
--item-name "$SERVER" \
--backup-management-type "$BACKUP_MANAGEMENT_TYPE" \
--query "sort_by([?properties.recoveryPointTime != null && contains(to_string(properties.recoveryPointTime), '$RESTORE_DATE')], &properties.recoveryPointTime)[-1].name" \
--output tsv)
if [ -z "$LATEST_RESTORE_POINT" ]; then
echo "No restore points found for $SERVER on date $RESTORE_DATE" >&2
continue
fi
echo "Found latest restore point for $SERVER: $LATEST_RESTORE_POINT"
echo "Triggering restore for $SERVER using restore point $LATEST_RESTORE_POINT..."
if az backup restore restore-disks \
--resource-group "$RESOURCE_GROUP" \
--vault-name "$RECOVERY_VAULT" \
--container-name "$SERVER" \
--item-name "$SERVER" \
--rp-name "$LATEST_RESTORE_POINT" \
--target-resource-group "$TARGET_RG" \
--restore-mode "OriginalLocation" \
--storage-account "$STORAGE_ACCOUNT" \
--storage-account-resource-group "$TARGET_RG"; then
echo "Restore for $SERVER triggered successfully."
else
echo "Failed to trigger restore for $SERVER." >&2
fi
done
While performing the restore via CLI, a backup is taken before the restore operation, but I’d like to skip this backup step, as I don’t require it and it adds unnecessary time and resources to the restore process.
Is there a flag or setting in the CLI that would allow me to skip this pre-restore backup, similar to the Portal option?
Any help or guidance would be greatly appreciated.
Thank you!
Best regards,
Mayu
1 answer
Sort by: Most helpful
-
Udayashankar K.N 240 Reputation points Microsoft Employee
2025-02-10T14:17:05.91+00:00