Skip to content

azurermBackupPolicyVmWorkload

Manages an Azure VM Workload Backup Policy within a Recovery Services vault.

Example Usage

/*Provider bindings are generated by running cdktf get.
See https://cdk.tf/provider-generation for more details.*/
import * as azurerm from "./.gen/providers/azurerm";
/*The following providers are missing schema information and might need manual adjustments to synthesize correctly: azurerm.
For a more precise conversion please use the --provider flag in convert.*/
const azurermResourceGroupExample = new azurerm.resourceGroup.ResourceGroup(
  this,
  "example",
  {
    location: "West Europe",
    name: "example-bpvmw",
  }
);
const azurermRecoveryServicesVaultExample =
  new azurerm.recoveryServicesVault.RecoveryServicesVault(this, "example_1", {
    location: azurermResourceGroupExample.location,
    name: "example-rsv",
    resource_group_name: azurermResourceGroupExample.name,
    sku: "Standard",
    soft_delete_enabled: false,
  });
/*This allows the Terraform resource name to match the original name. You can remove the call if you don't need them to match.*/
azurermRecoveryServicesVaultExample.overrideLogicalId("example");
const azurermBackupPolicyVmWorkloadExample =
  new azurerm.backupPolicyVmWorkload.BackupPolicyVmWorkload(this, "example_2", {
    name: "example-bpvmw",
    protection_policy: [
      {
        backup: [
          {
            frequency: "Daily",
            time: "15:00",
          },
        ],
        policy_type: "Full",
        retention_daily: [
          {
            count: 8,
          },
        ],
      },
      {
        backup: [
          {
            frequency_in_minutes: 15,
          },
        ],
        policy_type: "Log",
        simple_retention: [
          {
            count: 8,
          },
        ],
      },
    ],
    recovery_vault_name: azurermRecoveryServicesVaultExample.name,
    resource_group_name: azurermResourceGroupExample.name,
    settings: [
      {
        compression_enabled: false,
        time_zone: "UTC",
      },
    ],
    workload_type: "SQLDataBase",
  });
/*This allows the Terraform resource name to match the original name. You can remove the call if you don't need them to match.*/
azurermBackupPolicyVmWorkloadExample.overrideLogicalId("example");

Argument Reference

The following arguments are supported:

  • name - (Required) The name of the VM Workload Backup Policy. Changing this forces a new resource to be created.

  • resourceGroupName - (Required) The name of the resource group in which to create the VM Workload Backup Policy. Changing this forces a new resource to be created.

  • recoveryVaultName - (Required) The name of the Recovery Services Vault to use. Changing this forces a new resource to be created.

  • protectionPolicy - (Required) One or more protectionPolicy blocks as defined below.

  • settings - (Required) A settings block as defined below.

  • workloadType - (Required) The VM Workload type for the Backup Policy. Possible values are sqlDataBase and sapHanaDatabase. Changing this forces a new resource to be created.


The protectionPolicy block supports the following:

  • policyType - (Required) The type of the VM Workload Backup Policy. Possible values are differential, full, incremental and log.

  • backup - (Required) A backup block as defined below.

  • retentionDaily - (Optional) A retentionDaily block as defined below.

  • retentionWeekly - (Optional) A retentionWeekly block as defined below.

  • retentionMonthly - (Optional) A retentionMonthly block as defined below.

  • retentionYearly - (Optional) A retentionYearly block as defined below.

  • simpleRetention - (Optional) A simpleRetention block as defined below.


The simpleRetention block supports the following:

  • count - (Required) The count that is used to count retention duration with duration type days. Possible values are between 7 and 35.

The settings block supports the following:

  • timeZone - (Required) The timezone for the VM Workload Backup Policy. The possible values are defined here.

  • compressionEnabled - (Optional) The compression setting for the VM Workload Backup Policy. Defaults to false.


The backup block supports the following:

  • frequency - (Optional) The backup frequency for the VM Workload Backup Policy. Possible values are daily and weekly.

  • frequencyInMinutes - (Optional) The backup frequency in minutes for the VM Workload Backup Policy. Possible values are 15, 30, 60, 120, 240, 480, 720 and 1440.

  • time - (Optional) The time of day to perform the backup in 24hour format.

  • weekdays - (Optional) The days of the week to perform backups on. Possible values are sunday, monday, tuesday, wednesday, thursday, friday or saturday. This is used when frequency is weekly.


The retentionDaily block supports the following:

  • count - (Required) The number of daily backups to keep. Possible values are between 7 and 9999.

The retentionWeekly block supports the following:

  • count - (Required) The number of weekly backups to keep. Possible values are between 1 and 5163.

  • weekdays - (Required) The weekday backups to retain. Possible values are sunday, monday, tuesday, wednesday, thursday, friday or saturday.


The retentionMonthly block supports the following:

  • count - (Required) The number of monthly backups to keep. Must be between 1 and 1188.

  • formatType - (Required) The retention schedule format type for monthly retention policy. Possible values are daily and weekly.

  • monthdays - (Optional) The monthday backups to retain. Possible values are between 0 and 28.

  • weekdays - (Optional) The weekday backups to retain. Possible values are sunday, monday, tuesday, wednesday, thursday, friday or saturday.

  • weeks - (Optional) The weeks of the month to retain backups of. Possible values are first, second, third, fourth and last.


The retentionYearly block supports the following:

  • count - (Required) The number of yearly backups to keep. Possible values are between 1 and 99

  • formatType - (Required) The retention schedule format type for yearly retention policy. Possible values are daily and weekly.

  • months - (Required) The months of the year to retain backups of. Possible values are january, february, march, april, may, june, july, august, september, october, november and december.

  • monthdays - (Optional) The monthday backups to retain. Possible values are between 0 and 28.

  • weekdays - (Optional) The weekday backups to retain. Possible values are sunday, monday, tuesday, wednesday, thursday, friday or saturday.

  • weeks - (Optional) The weeks of the month to retain backups of. Possible values are first, second, third, fourth, last.

Attributes Reference

The following attributes are exported:

  • id - The ID of the Azure VM Workload Backup Policy.

Timeouts

The timeouts block allows you to specify timeouts for certain actions:

  • create - (Defaults to 30 minutes) Used when creating the VM Workload Backup Policy.
  • update - (Defaults to 30 minutes) Used when updating the VM Workload Backup Policy.
  • read - (Defaults to 5 minutes) Used when retrieving the VM Workload Backup Policy.
  • delete - (Defaults to 30 minutes) Used when deleting the VM Workload Backup Policy.

Import

Azure VM Workload Backup Policies can be imported using the resourceId, e.g.

terraform import azurerm_backup_policy_vm_workload.policy1 /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/group1/providers/Microsoft.RecoveryServices/vaults/vault1/backupPolicies/policy1