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

Feature Request: Backup Policy type "SQL Server in Azure VM" #3910

Open
joeyjesky opened this issue Jul 23, 2019 · 32 comments
Open

Feature Request: Backup Policy type "SQL Server in Azure VM" #3910

joeyjesky opened this issue Jul 23, 2019 · 32 comments

Comments

@joeyjesky
Copy link

joeyjesky commented Jul 23, 2019

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

Description

The ability to create a backup policy for Policy Type = 'SQL Server in Azure VM'

New or Affected Resource(s)

Cannot create backup policy for SQL Server in Azure VM.

  • azurerm_recovery_services_protection_policy_vm

Potential Terraform Configuration

       {
  "condition": "[parameters('isNewPolicy')]",
  "type": "Microsoft.RecoveryServices/vaults/backupPolicies",
  "apiVersion": "2018-01-10",
  "name": "[concat(parameters('vaultName'), '/', parameters('policyName'))]",
  "dependsOn": [
    "[resourceId('Microsoft.RecoveryServices/vaults/', parameters('vaultName'))]"
  ],
  "properties": {
    "backupManagementType": "[variables('backupManagementType')]",
    "workloadType": "[parameters('workloadType')]",
    "settings": {
      "timeZone": "UTC",
      "issqlcompression": false,
      "isCompression": false
    },
    "subProtectionPolicy": [
      {
        "policyType": "Full",
        "schedulePolicy": {
            "schedulePolicyType": "SimpleSchedulePolicy",
            "scheduleRunFrequency": "Daily",
            "scheduleRunTimes": [
                "2019-03-24T16:00:00Z"
            ],
            "scheduleWeeklyFrequency": 0
        },
        "retentionPolicy": {
            "retentionPolicyType": "LongTermRetentionPolicy",
            "dailySchedule": {
                "retentionTimes": [
                    "2019-03-24T16:00:00Z"
                ],
                "retentionDuration": {
                    "count": 30,
                    "durationType": "Days"
                }
            }
        }
      },
      {
          "policyType": "Log",
          "schedulePolicy": {
              "schedulePolicyType": "LogSchedulePolicy",
              "scheduleFrequencyInMins": 60
          },
          "retentionPolicy": {
              "retentionPolicyType": "SimpleRetentionPolicy",
              "retentionDuration": {
                  "count": 30,
                  "durationType": "Days"
              }
          }
      }
    ]
  }
},

References

https://github.com/Azure/azure-quickstart-templates/tree/master/101-recovery-services-vm-workload-backup

  • #0000
@joeyjesky joeyjesky changed the title Backup Policy type "SQL Server in Azure VM" Feature Request: Backup Policy type "SQL Server in Azure VM" Jul 23, 2019
@Rod-Sychev

This comment has been minimized.

@Sam123ben

This comment has been minimized.

@nicksin-leroux

This comment has been minimized.

@liomaz

This comment has been minimized.

@ChorltonPaul

This comment has been minimized.

@starskythehutch

This comment has been minimized.

@nbishopfnts

This comment has been minimized.

@A30001546

This comment has been minimized.

@mpjtaylor
Copy link

also need this

@hriaz
Copy link

hriaz commented Jan 4, 2022

The issue / feature request applies to workload-type= SAPHANA

@benj-ch
Copy link

benj-ch commented Jan 18, 2022

Extremely interested in this. Any updates on this request ?

@aronoeldb
Copy link

Interested in this, any update?

@jackwesleyroper
Copy link

Also need this feature!

@petri-o-ojala
Copy link

Azure Backup for Workloads definetly needs some love and support, multiple customer cases where we'd need native Terraform support for this feature (with HANA but should be implemented across the board).

@dileepalbert
Copy link

Extremely interested see any progress on this topic

@davidsampson-hv
Copy link

We also really need support for SQL in Azure VM policies

@Sam123ben
Copy link

Any update on this please??? We need this ASAP to complete out Vault Service autmation.

@flappje
Copy link

flappje commented Aug 19, 2022

I was also looking how I could add SQL to Recovery Servies Vault and I found this PR: #17765
I think this could be the solution for this Issue. so let's hope they merge this soon

@pvrk
Copy link

pvrk commented Sep 1, 2022

This functionality is now released with provider version 3.20.0. Please see the details of the issue, mentioned above.

@ArjunMR89
Copy link

I am trying to backup SQL in Azure VM and used the policy azurerm_backup_policy_vm_workload with azurerm provider version 3.23.0. The policy is successfully deployed in Azure but I couldn't find any resource to backup SQL in Azure VM. I tried using azurerm_backup_protected_vm by passing virtualMachines ID and SqlVirtualMachines ID but both resulted in errors. Am I missing something? Is only backup policy available at the moment? Is the backup of SQL in Azure VM still not supported using Terraform?

Vm_ID_Error

SqlVm_ID_Error

@pvrk
Copy link

pvrk commented Sep 20, 2022

@ArjunMR89 : Yes, currently only backup policy is available on Terraform. We are working on integration SQL backup too. So, you have the Azure VM registered as SQL VM?

@ArjunMR89
Copy link

@pvrk Thank you for the reply. Yes, I have Azure VM registered as SQL VM. Could you please suggest any workaround till the SQL backup is released?

@mpjtaylor
Copy link

i am using azapi_resource for now

@jschwellnus92
Copy link
Contributor

i am using azapi_resource for now

Any chance you can share your working code?

@mpjtaylor
Copy link

Just created the policy in Azure and exported the json and then used this

resource "azapi_resource" "SQLBackupPolicy" {
  name                    = var.policy_name
  parent_id               = azurerm_recovery_services_vault.sqlsupport.id
  type                    = "Microsoft.RecoveryServices/vaults/backupPolicies@2022-03-01"
  ignore_missing_property = false
  body = templatefile("${path.module}/templates/${var.policy_name}.json.tftpl", {
    "timezone" : var.timezone
  })
  schema_validation_enabled = false
}

@benj-ch
Copy link

benj-ch commented Dec 1, 2022

The resource has been released in August: azurerm_backup_policy_vm_workload

https://github.com/hashicorp/terraform-provider-azurerm/releases/tag/v3.20.0

@petri-o-ojala
Copy link

petri-o-ojala commented Dec 23, 2022

The documentation has an example

  protection_policy {
    policy_type = "Log"

    backup {
      frequency_in_minutes = 15
    }

    simple_retention {
      count = 8
    }
  }

And when trying to deploy almost identical configuration:

        + protection_policy {
          + policy_type = "Log"

          + backup {
              + frequency_in_minutes = 60
              + weekdays             = []
            }

          + retention_daily {
              + count = 35
            }
        }

It fails with not-so-clear error

Status=400 Code="BMSUserErrorInvalidPolicyInput" Message="Input for create or update policy is not in proper format. Please check format of parameters like schedule time, schedule days, retention time and retention days "

The provider (azurerm 3.37) adds weekdays eventhough it's not defined in the code.

@benj-ch
Copy link

benj-ch commented Dec 23, 2022

There is no frequency_in_minutes in "backup" (I don't see it in the documentation).

There is frequency = "Hourly"

The weekdays is just initialized, even it's not defined in the code.
There are many examples of Terraform resource which works like that.

@petri-o-ojala
Copy link

https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/backup_policy_vm_workload#frequency_in_minutes

Considering that there are only a few parameters in the Log policy (and the protection_policy is exactly the same as in the documentation example), my assumption was that the Azure API is complaining due to the weekdays[], didn't check what terraform is sending to the API. Could be something else, too.

We have had working code for workload backup policies a long time through ARM deployment with azurerm_resource_group_template_deployment and I was just planning to switch to AzAPI when I noticed that the new native resource exists, which we would prefer but it worked only for the weekly and daily policies, not for the Log policy. The Log policy there deploys fine with protection policy:

                    {
                        policyType      = "Log"
                        retentionPolicy = {
                            retentionDuration   = {
                                count        = 35
                                durationType = "Days"
                            }
                            retentionPolicyType = "SimpleRetentionPolicy"
                        }
                        schedulePolicy  = {
                            scheduleFrequencyInMins = 15
                            schedulePolicyType      = "LogSchedulePolicy"
                        }
                    }

@gebalam
Copy link

gebalam commented Jul 8, 2024

hi, any update on that?
azurerm_backup_policy_vm_workload is one thing but still I'm missing something like: azurerm_backup_protected_vm for MSSQL VM. so I could cover in code scenario with backing up databases from SQL VM with recovery services vault.

@frostsxx
Copy link
Contributor

frostsxx commented Nov 15, 2024

Hi guys,

Any updates on this?

ATM we can only create VM Workload but there is no way to associate SQL VM's to that Workload using Terraform...

@broomfn
Copy link

broomfn commented Dec 11, 2024

+1 I was hoping to automate this setup too, but wasn't obvious and I ended up here, I guess for the moment I'll have to use the Azure Portal to manually configure 😢

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests