ansible-collections / azure

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

azure_rm_backuppolicy support different intervals at the same time #1491

Open JeromeBollinger opened 8 months ago

JeromeBollinger commented 8 months ago
SUMMARY

Currently it is not possible to define a policy which does daily and weekly backups (or possibly other combinations). A way around it is to create different policies which does only one of the backup intervals and then assign the vm to both policies. However, this can result in an error if the operations are done in a rapid succession:

Error in creating/updating protection for Azure VM (BMSUserErrorObjectLocked) Another operation is in progress on the selected item.
Code: BMSUserErrorObjectLocked
Message: Another operation is in progress on the selected item.
ISSUE TYPE
COMPONENT NAME

azure_rm_backuppolicy

ADDITIONAL INFORMATION

Might look like this:

- name: Ensure Policy for weekly and Daily backups exists
  azure.azcollection.azure_rm_backuppolicy:
    vault_name: "{{ vaule_name }}"
    name: "{{ policy_name }}"
    resource_group: "{{ rg }}"
    state: present
    backup_management_type: "AzureIaasVM"
    schedule_run_frequency: "Weekly,Daily"
    schedule_days:
      - "Sunday"
    schedule_run_time: "4"
    instant_recovery_snapshot_retention_daily: 2
    daily_retention_count: 32
    instant_recovery_snapshot_retention_weekly: 5
    weekly_retention_count: 18
    time_zone: "UTC"
    api_profile: "latest"
  tags: backup_vault

Azure does support this usecase, so I think it is possible to implement

Fred-sun commented 8 months ago

@JeromeBollinger Yes, this is normal behavior. If a second task is executed when the first task is incomplete, the second task will report an error because the resource used in the first task was not released. Thank you!

JeromeBollinger commented 7 months ago

Sorry for posting here again but Just for my understanding: was this closed because it is not a bug? I marked this ticket as feature request because I would like to be able to have different backup intervals in the same policy, as this is supported by azure but not in this module.

Fred-sun commented 7 months ago

@JeromeBollinger According to your error, your operation failed because a process was in progress. So I don't think it's a Bug. Could you explain your requirements in detail? This will help solve the problem you are experiencing. Thank you!

JeromeBollinger commented 7 months ago

First of all, Thank you for taking some time! So the error that I am experiencing comes from my workaround of having two different policies with different backup time interval. I understand, that this is not a bug. I would like to not be needing this workaround but instead having two or more different time intervals in one policy instead of different policies. This means, I would like to be able to specify that I want a daily backup and a weekly backup with different retention periods etc. This could look like the snippet that I send in my first comment.

I believe this should be possible as you can configure multiple backup intervals in one single policy in the azure portal