ansible-collections / azure

Development area for Azure Collections
https://galaxy.ansible.com/azure/azcollection
GNU General Public License v3.0
247 stars 330 forks source link

Restore VM from Backup #1692

Open Klaas- opened 1 month ago

Klaas- commented 1 month ago
SUMMARY

I would like the possiblity to restore a virtual machine from backup via ansible. Primary usecase is I want to automate recovery tests and restoring the actual backup is a crucial part of that :)

There two types of restores: 1) Replace VM, this will replace an existing VM with an older version of the same VM (most common scenario I would say). It will however not replace the disks, but create new disks and reconfigure VM to use the new ones 2) Create new VM from backup, this means you can use your backup to create a new VM from it. I've included this for feature parity with the portal, but my interest is primarily in scanario 1)

I think this also needs an addition to the azure.azcollection.azure_rm_backupazurevm_info to list all available backups, currently it only supplies information about the last backup.

ISSUE TYPE
COMPONENT NAME

I think this could be part of azure.azcollection.azure_rm_backupazurevm or become a new module

ADDITIONAL INFORMATION
azure.azcollection.azure_rm_backupazurevm:
  state: restore
  backup_id: "{{ id_of_backup_you_want_to_restore }}"
Klaas- commented 1 month ago

List of available backups is coming from here: https://learn.microsoft.com/en-us/rest/api/backup/recovery-points/list?view=rest-backup-2024-04-01&tabs=Python#code-try-0