Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Azure recovery service vault backup retentionTimes and scheduleRunTimes dates are incorrect on creation of policy #23582

Closed
1 task done
maltaf1 opened this issue Oct 16, 2023 · 5 comments · Fixed by #23586

Comments

@maltaf1
Copy link

maltaf1 commented Oct 16, 2023

Is there an existing issue for this?

  • I have searched the existing issues

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or "me too" comments, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment and review the contribution guide to help.

Terraform Version

1.3.7

AzureRM Provider Version

3.70.0

Affected Resource(s)/Data Source(s)

azurerm_backup_policy_vm

Terraform Configuration Files

#tfvars file:

backup_policy_list = {
  mydefault = {
    policy_name                    =  "MyVMDefaultPolicy"
    policy_type                    =  "V2"
    policy_timezone                =  "UTC"
    instant_restore_retention_days = 7
    backup_policy_backup = [
      { frequency     = "Daily", time = "23:00", hour_interval = null, hour_duration = null }
    ]
    backup_policy_retention_daily = [
      { count = "7" }
    ]
    backup_policy_retention_weekly  = [
      { 
        count = 4  
        weekdays = ["Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"] 
      }
    ]
    backup_policy_retention_monthly = [
      { 
        count    = 12 
        weekdays = ["Sunday"] 
        weeks    = ["First","Last"]
      }
    ]
    backup_policy_retention_yearly  = [
      {
        count    = 4  
        weekdays = ["Sunday"] 
        weeks    = ["Last"] 
        months   = ["January"] 
      }
    ]
  }

===============================================================
module:

resource "azurerm_backup_policy_vm" "backup_policy" {  
for_each = { for idx,val in var.backup_policy_list: idx => val }    
  resource_group_name            = var.backup_policy_res_group_name
  recovery_vault_name            = var.backup_policy_vault_name 
  name                           = each.value.policy_name
  policy_type                    = each.value.policy_type
  timezone                       = each.value.policy_timezone
  instant_restore_retention_days = each.value.instant_restore_retention_days
    dynamic "backup"{
    for_each = each.value.backup_policy_backup
    content {
      frequency     = backup.value["frequency"]
      time          = backup.value["time"]
      hour_interval = backup.value["hour_interval"]
      hour_duration = backup.value["hour_duration"]
    }
  }  
dynamic "retention_daily" {
    for_each = each.value.backup_policy_retention_daily
    content {
      count = retention_daily.value["count"]
    }
  }

    dynamic "retention_weekly" {
    for_each = each.value.backup_policy_retention_weekly
    content {
      count    = retention_weekly.value["count"]
      weekdays = retention_weekly.value["weekdays"]

    }
  }

    dynamic "retention_monthly" {
    for_each = each.value.backup_policy_retention_monthly
    content {
      count    = retention_monthly.value["count"]
      weekdays = retention_monthly.value["weekdays"]
      weeks    = retention_monthly.value["weeks"]
    }
  }

Debug Output/Panic Output

{
    "status": "Failed",
    "error": {
        "code": "CloudInternalError",
        "message": "Microsoft Azure Backup encountered an internal error."
    }
}

Expected Behaviour

I would expect to be able to backup my VMs with my custom backup polices. However I have unable to do so.

Actual Behaviour

After successfully creating a backup policy, I was unable to use this to backup a vm (see internal error above)

On investigation I have noticed the following date stamps to be in the past (2018-07-30T23:00:00Z):

export file of the policies:

{
            "type": "Microsoft.RecoveryServices/vaults/backupPolicies",
            "apiVersion": "2023-04-01",
            "name": "[concat(parameters('vaults_sv_dev_eastus_recoveryvault_billing_name'), '/MyDefaultPolicy')]",
            "dependsOn": [
                "[resourceId('Microsoft.RecoveryServices/vaults', parameters('vaults_sv_dev_eastus_recoveryvault_billing_name'))]"
            ],
            "properties": {
                "backupManagementType": "AzureIaasVM",
                "policyType": "V2",
                "instantRPDetails": {},
                "schedulePolicy": {
                    "schedulePolicyType": "SimpleSchedulePolicyV2",
                    "scheduleRunFrequency": "Daily",
                    "dailySchedule": {
                        "scheduleRunTimes": [
                            "2018-07-30T23:00:00Z"
                        ]
                    }
                },
                "retentionPolicy": {
                    "retentionPolicyType": "LongTermRetentionPolicy",
                    "dailySchedule": {
                        "retentionTimes": [
                            "2018-07-30T23:00:00Z"
                        ],
                        "retentionDuration": {
                            "count": 7,
                            "durationType": "Days"
                        }
                    },
                    "weeklySchedule": {
                        "daysOfTheWeek": [
                            "Thursday",
                            "Friday",
                            "Wednesday",
                            "Saturday",
                            "Tuesday",
                            "Monday",
                            "Sunday"
                        ],
                        "retentionTimes": [
                            "2018-07-30T23:00:00Z"
                        ],
                        "retentionDuration": {
                            "count": 4,
                            "durationType": "Weeks"
                        }
                    },
                    "monthlySchedule": {
                        "retentionScheduleFormatType": "Weekly",
                        "retentionScheduleWeekly": {
                            "daysOfTheWeek": [
                                "Sunday"
                            ],
                            "weeksOfTheMonth": [
                                "Last",
                                "First"
                            ]
                        },
                        "retentionTimes": [
                            "2018-07-30T23:00:00Z"
                        ],
                        "retentionDuration": {
                            "count": 12,
                            "durationType": "Months"
                        }
                    },
                    "yearlySchedule": {
                        "retentionScheduleFormatType": "Weekly",
                        "monthsOfYear": [
                            "January"
                        ],
                        "retentionScheduleWeekly": {
                            "daysOfTheWeek": [
                                "Sunday"
                            ],
                            "weeksOfTheMonth": [
                                "Last"
                            ]
                        },
                        "retentionTimes": [
                            "2018-07-30T23:00:00Z"
                        ],
                        "retentionDuration": {
                            "count": 4,
                            "durationType": "Years"
                        }
                    }
                },
                "instantRpRetentionRangeInDays": 7,
                "timeZone": "UTC",
                "protectedItemsCount": 0
            }
        },


Steps to Reproduce

No response

Important Factoids

No response

References

No response

ziyeqf added a commit to ziyeqf/terraform-provider-azurerm that referenced this issue Oct 17, 2023
@ziyeqf
Copy link
Contributor

ziyeqf commented Oct 17, 2023

Hi @maltaf1, thanks for reporting.

I have submitted a PR(#23586) to fix the retentionTimes paramter, once it merged and released, the parameter should be correct.

For any further questions, please leave comments.
Thanks!

@maltaf1
Copy link
Author

maltaf1 commented Oct 17, 2023

The problem is also with "scheduleRunTimes"

@ziyeqf
Copy link
Contributor

ziyeqf commented Oct 17, 2023

The problem is also with "scheduleRunTimes"

it was also included, thanks.

@rcskosir rcskosir added the bug label Oct 18, 2023
@rcskosir rcskosir linked a pull request Oct 18, 2023 that will close this issue
@maltaf1
Copy link
Author

maltaf1 commented Oct 20, 2023

Any idea when this fix will be part of an official a released ?

Copy link

github-actions bot commented May 3, 2024

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 3, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants