Delen via


New-AzDataProtectionBackupPolicy

Hiermee maakt u een nieuw back-upbeleid in een bepaalde back-upkluis

Syntaxis

New-AzDataProtectionBackupPolicy
   -ResourceGroupName <String>
   -VaultName <String>
   -Name <String>
   -Policy <IBackupPolicy>
   [-SubscriptionId <String>]
   [-DefaultProfile <PSObject>]
   [-WhatIf]
   [-Confirm]
   [<CommonParameters>]

Description

Hiermee maakt u een nieuw back-upbeleid in een bepaalde back-upkluis

Voorbeelden

Voorbeeld 1: Een standaardbeleid maken

$defaultPol = Get-AzDataProtectionPolicyTemplate -DatasourceType AzureDisk
New-AzDataProtectionBackupPolicy -SubscriptionId "xxxx-xxx-xxx" -ResourceGroupName sarath-rg -VaultName sarath-vault -Name "MyPolicy" -Policy $defaultPol

Name              Type
----              ----
MyPolicy       Microsoft.DataProtection/backupVaults/backupPolicies

Met deze opdracht maakt u een standaardbeleid voor het gegevensbrontype azure-schijf.

Voorbeeld 2: Een beleid maken voor AzureDatabaseForPostgreSQL, in dit voorbeeld wordt een complex beleid behandeld met behulp van PowerShell

$defaultPol = Get-AzDataProtectionPolicyTemplate -DatasourceType AzureDatabaseForPostgreSQL
$lifeCycleVault = New-AzDataProtectionRetentionLifeCycleClientObject -SourceDataStore VaultStore -SourceRetentionDurationType Months -SourceRetentionDurationCount 3 -TargetDataStore ArchiveStore -CopyOption CopyOnExpiryOption
$lifeCycleArchive = New-AzDataProtectionRetentionLifeCycleClientObject -SourceDataStore ArchiveStore -SourceRetentionDurationType Months -SourceRetentionDurationCount 6
Edit-AzDataProtectionPolicyRetentionRuleClientObject -Policy $defaultPol -Name Default -LifeCycles $lifeCycleVault, $lifeCycleArchive -IsDefault $true
$schDates = @(
(
    (Get-Date -Year 2021 -Month 08 -Day 18 -Hour 10 -Minute 0 -Second 0)
),
(
    (Get-Date -Year 2021 -Month 08 -Day 22 -Hour 10 -Minute 0 -Second 0) 
))

$trigger =  New-AzDataProtectionPolicyTriggerScheduleClientObject -ScheduleDays $schDates -IntervalType Weekly -IntervalCount 1
Edit-AzDataProtectionPolicyTriggerClientObject -Schedule $trigger -Policy $defaultPol   
$lifeCycleVault = New-AzDataProtectionRetentionLifeCycleClientObject -SourceDataStore VaultStore -SourceRetentionDurationType Months -SourceRetentionDurationCount 6 -TargetDataStore ArchiveStore -CopyOption CopyOnExpiryOption
$lifeCycleArchive = New-AzDataProtectionRetentionLifeCycleClientObject -SourceDataStore ArchiveStore -SourceRetentionDurationType Months -SourceRetentionDurationCount 12
Edit-AzDataProtectionPolicyRetentionRuleClientObject -Policy $defaultPol -Name Monthly -LifeCycles $lifeCycleVault, $lifeCycleArchive -IsDefault $false
$tagCriteria = New-AzDataProtectionPolicyTagCriteriaClientObject -AbsoluteCriteria FirstOfMonth
Edit-AzDataProtectionPolicyTagClientObject -Policy $defaultPol -Name Monthly -Criteria $tagCriteria
New-AzDataProtectionBackupPolicy -SubscriptionId "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" -ResourceGroupName "resourceGroupName" -VaultName "vaultName" -Name "newOSSPolicy" -Policy $defaultPol

Name              Type
----              ----
newOSSPolicy       Microsoft.DataProtection/backupVaults/backupPolicies

Met de eerste opdracht wordt de standaardbeleidssjabloon voor AzureDatabaseForPostgreSQL ophaalt. De tweede, derde opdrachten maken twee verschillende back-uplevenscycli voor de kluis en archiefopslag. De back-up blijft gedurende 3 maanden in de kluisopslag en kopieert na verloop van tijd naar het archief en blijft daar tot 6 maanden. Met de vierde opdracht wordt het beleidsobject bijgewerkt met levenscycluss die zijn gemaakt. De vijfde, zesde opdrachten maken het aangepaste planningsobject voor het back-upbeleid, twee keer per week vanaf $schDates. Met de zevende opdracht wordt het beleidsobject bijgewerkt met een aangepast schema. Met de achtste, negende, tiende opdrachten wordt de maandelijkse bewaarregel bijgewerkt met aangepaste levenscycluss. Met de elfde, twaalfde opdracht maakt u een tagcriteria voor maandelijks beleid. Tagcriteria moeten worden toegevoegd voor elke aangepaste bewaarregel (automatisch toegevoegd voor standaardretentieregel). Met de laatste opdracht wordt het beleid gemaakt.

Voorbeeld 3: Een beleid maken voor AzureKubernetesService

$defaultPol = Get-AzDataProtectionPolicyTemplate -DatasourceType AzureKubernetesService
$schDate = @(
(
    (Get-Date -Year 2023 -Month 03 -Day 18 -Hour 16 -Minute 0 -Second 0)
))
$trigger =  New-AzDataProtectionPolicyTriggerScheduleClientObject -ScheduleDays $schDate -IntervalType Daily -IntervalCount 1
Edit-AzDataProtectionPolicyTriggerClientObject -Schedule $trigger -Policy $defaultPol
$lifeCycleDaily = New-AzDataProtectionRetentionLifeCycleClientObject -SourceDataStore OperationalStore -SourceRetentionDurationType Days -SourceRetentionDurationCount 8
$lifeCycleWeekly = New-AzDataProtectionRetentionLifeCycleClientObject -SourceDataStore OperationalStore -SourceRetentionDurationType Weeks -SourceRetentionDurationCount 9
Edit-AzDataProtectionPolicyRetentionRuleClientObject -Policy $defaultPol -Name Daily -LifeCycles $lifeCycleDaily -IsDefault $false
Edit-AzDataProtectionPolicyRetentionRuleClientObject -Policy $defaultPol -Name Weekly -LifeCycles $lifeCycleWeekly -IsDefault $false
$tagCriteriaDaily = New-AzDataProtectionPolicyTagCriteriaClientObject -AbsoluteCriteria FirstOfDay
Edit-AzDataProtectionPolicyTagClientObject -Policy $defaultPol -Name Daily -Criteria $tagCriteriaDaily
$tagCriteriaWeekly = New-AzDataProtectionPolicyTagCriteriaClientObject -AbsoluteCriteria FirstOfWeek 
Edit-AzDataProtectionPolicyTagClientObject -Policy $defaultPol -Name Weekly -Criteria $tagCriteriaWeekly
$newPolicy = New-AzDataProtectionBackupPolicy -ResourceGroupName "resourceGroupName" -VaultName "vaultName" -Name "newAKSPolicy" -Policy $defaultPol -SubscriptionId "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"

Name              Type
----              ----
newAKSPolicy       Microsoft.DataProtection/backupVaults/backupPolicies

Met de eerste opdracht wordt de standaardbeleidssjabloon voor AzureKubernetesService ophaalt. Met de tweede, derde opdrachten maakt u het aangepaste planningsobject voor het back-upbeleid, dagelijks vanaf $schDate. Met de vierde opdracht wordt het beleidsobject bijgewerkt met aangepaste planning. De vijfde, zesde opdrachten maken twee back-uplevenscycli voor dagelijkse en wekelijkse herstelpunten. De zevende acht opdrachten werken het beleidsobject bij met levenscycluss die zijn gemaakt. Vervolgens maken we FirstOfDay, FirstOfWeek-tagcriteria en werken we het beleid bij. Met de laatste opdracht wordt het beleid gemaakt.

Voorbeeld 4: Een operationeel beleid maken voor AzureBlob

$defaultPol = Get-AzDataProtectionPolicyTemplate -DatasourceType AzureBlob
Edit-AzDataProtectionPolicyTriggerClientObject -Policy $defaultPol -RemoveSchedule
$lifeCycleOperationalTier = New-AzDataProtectionRetentionLifeCycleClientObject -SourceDataStore OperationalStore -SourceRetentionDurationType Days -SourceRetentionDurationCount 30
Edit-AzDataProtectionPolicyRetentionRuleClientObject -Policy $defaultPol -Name Default -LifeCycles $lifeCycleOperationalTier -IsDefault $true -OverwriteLifeCycle $true
$opPolicy = New-AzDataProtectionBackupPolicy -SubscriptionId "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" -ResourceGroupName "resourceGroupName" -VaultName "vaultName" -Name "operationalPolicyName" -Policy $defaultPol

Name                        Type
----                        ----
operationalPolicyName       Microsoft.DataProtection/backupVaults/backupPolicies

Met de eerste opdracht wordt de standaardbeleidssjabloon voor AzureBlob ophaalt. Beleidssjabloon is standaard gekluisd beleid. Met de tweede opdracht wordt de gekluisde beleidsplanning verwijderd omdat we operationeel beleid maken. Met de derde opdracht maakt u een operationele winkellevenscyclus voor 30 dagen. Met de vierde opdracht wordt de levenscyclus van de kluis overschreven met de levenscyclus van operationele opslag. Met de laatste opdracht wordt het operationele archiefbeleid gemaakt.

Voorbeeld 4: Een kluisbeleid maken voor AzureBlob

$defaultPol = Get-AzDataProtectionPolicyTemplate -DatasourceType AzureBlob
$lifeCycleVaultTierWeekly = New-AzDataProtectionRetentionLifeCycleClientObject -SourceDataStore VaultStore -SourceRetentionDurationType Weeks -SourceRetentionDurationCount 4
Edit-AzDataProtectionPolicyRetentionRuleClientObject -Policy $defaultPol -Name Weekly -LifeCycles $lifeCycleVaultTierWeekly -IsDefault $false
$tagCriteria = New-AzDataProtectionPolicyTagCriteriaClientObject -AbsoluteCriteria FirstOfWeek
Edit-AzDataProtectionPolicyTagClientObject -Policy $defaultPol -Name Weekly -Criteria $tagCriteria
$vaultedPolicy = New-AzDataProtectionBackupPolicy -SubscriptionId "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" -ResourceGroupName "resourceGroupName" -VaultName "vaultName" -Name "vaultedPolicyName" -Policy $defaultPol

Name                        Type
----                        ----
vaultedPolicyName       Microsoft.DataProtection/backupVaults/backupPolicies

Met de eerste opdracht wordt de standaardsjabloon voor gekluisd beleid voor AzureBlob opgehaald. Met de tweede opdracht wordt een wekelijkse levenscyclus in de kluisopslag gedefinieerd. Met de derde opdracht wordt het standaardPol-object bijgewerkt met de wekelijkse levenscyclus. Met de derde en vierde opdracht wordt de defaultPol gedefinieerd en bijgewerkt met wekelijkse tagcriteria. Met de laatste opdracht wordt het archiefbeleid voor de kluis gemaakt.

Voorbeeld 5: Een operationeel en gekluisd beleid maken voor AzureBlob

$defaultPol = Get-AzDataProtectionPolicyTemplate -DatasourceType AzureBlob
$lifeCycleOperationalTier = New-AzDataProtectionRetentionLifeCycleClientObject -SourceDataStore OperationalStore -SourceRetentionDurationType Days -SourceRetentionDurationCount 30
Edit-AzDataProtectionPolicyRetentionRuleClientObject -Policy $defaultPol -Name Default -LifeCycles $lifeCycleOperationalTier -IsDefault $true -OverwriteLifeCycle $false  
$lifeCycleVaultTierWeekly = New-AzDataProtectionRetentionLifeCycleClientObject -SourceDataStore VaultStore -SourceRetentionDurationType Weeks -SourceRetentionDurationCount 7
Edit-AzDataProtectionPolicyRetentionRuleClientObject -Policy $defaultPol -Name Weekly -LifeCycles $lifeCycleVaultTierWeekly -IsDefault $false
$tagCriteria = New-AzDataProtectionPolicyTagCriteriaClientObject -AbsoluteCriteria FirstOfWeek
Edit-AzDataProtectionPolicyTagClientObject -Policy $defaultPol -Name Weekly -Criteria $tagCriteria
$lifeCycleVaultTierMonthly = New-AzDataProtectionRetentionLifeCycleClientObject -SourceDataStore VaultStore -SourceRetentionDurationType Months -SourceRetentionDurationCount 5
Edit-AzDataProtectionPolicyRetentionRuleClientObject -Policy $defaultPol -Name Monthly -LifeCycles $lifeCycleVaultTierMonthly -IsDefault $false
$tagCriteria = New-AzDataProtectionPolicyTagCriteriaClientObject -AbsoluteCriteria FirstOfMonth
Edit-AzDataProtectionPolicyTagClientObject -Policy $defaultPol -Name Monthly -Criteria $tagCriteria
$lifeCycleVaultTierYearly = New-AzDataProtectionRetentionLifeCycleClientObject -SourceDataStore VaultStore -SourceRetentionDurationType Years -SourceRetentionDurationCount 1
Edit-AzDataProtectionPolicyRetentionRuleClientObject -Policy $defaultPol -Name Yearly -LifeCycles $lifeCycleVaultTierYearly -IsDefault $false
$tagCriteria = New-AzDataProtectionPolicyTagCriteriaClientObject -AbsoluteCriteria FirstOfYear
Edit-AzDataProtectionPolicyTagClientObject -Policy $defaultPol -Name Yearly -Criteria $tagCriteria
$scheduleDate = Get-Date
$trigger =  New-AzDataProtectionPolicyTriggerScheduleClientObject -ScheduleDays $scheduleDate -IntervalType Weekly -IntervalCount 1
Edit-AzDataProtectionPolicyTriggerClientObject -Schedule $trigger -Policy $defaultPol
$defaultPol.PolicyRule[0].Trigger.ScheduleRepeatingTimeInterval[0] = "R/2023-05-09T02:30:00+01:00/P1W"
$timeZone = Get-TimeZone -ListAvailable | Where-Object { $_.Id -match "Europe" }
$defaultPol.PolicyRule[0].Trigger.ScheduleTimeZone = $timeZone[0].Id
$operationalVaultedPolicy = New-AzDataProtectionBackupPolicy -SubscriptionId "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" -ResourceGroupName "resourceGroupName" -VaultName "vaultName" -Name "operationalVaultedPolicyName" -Policy $defaultPol

Name                               Type
----                               ----
operationalVaultedPolicyName       Microsoft.DataProtection/backupVaults/backupPolicies

Met de eerste opdracht wordt de standaardsjabloon voor gekluisd beleid voor AzureBlob opgehaald. De tweede tot vijftiende opdracht definieert en werkt de operationele, gekluisde wekelijkse, maandelijkse, jaarlijkse levenscyclus en tagcriteria bij. Vervolgens definiƫren we een triggerobject met planningstijd en timzone, stelt u het in op standaardtijd van 2:30 AM - west Europa. Met de laatste opdracht maakt u het hybride AzureBlob-beleid.

Voorbeeld 6: Beleid maken voor AzureDatabaseForPGFlexServer/AzureDatabaseForMySQL

$defaultPol = Get-AzDataProtectionPolicyTemplate -DatasourceType AzureDatabaseForPGFlexServer
$lifeCycleVault = New-AzDataProtectionRetentionLifeCycleClientObject -SourceDataStore VaultStore -SourceRetentionDurationType Days -SourceRetentionDurationCount 10
Edit-AzDataProtectionPolicyRetentionRuleClientObject -Policy $defaultPol -Name Default -LifeCycles $lifeCycleVault -IsDefault $true
$lifeCycleVault = New-AzDataProtectionRetentionLifeCycleClientObject -SourceDataStore VaultStore -SourceRetentionDurationType Months -SourceRetentionDurationCount 6 
Edit-AzDataProtectionPolicyRetentionRuleClientObject -Policy $defaultPol -Name Monthly -LifeCycles $lifeCycleVault -IsDefault $false
$schDates = @(
(
    (Get-Date -Year 2024 -Month 03 -Day 04 -Hour 09 -Minute 0 -Second 0)
),
(
    (Get-Date -Year 2024 -Month 03 -Day 05 -Hour 09 -Minute 0 -Second 0)
))
$trigger =  New-AzDataProtectionPolicyTriggerScheduleClientObject -ScheduleDays $schDates -IntervalType Weekly -IntervalCount 1
Edit-AzDataProtectionPolicyTriggerClientObject -Schedule $trigger -Policy $defaultPol
$tagCriteria = New-AzDataProtectionPolicyTagCriteriaClientObject -MonthsOfYear January -DaysOfMonth 1,5,Last
Edit-AzDataProtectionPolicyTagClientObject -Policy $defaultPol -Name Monthly -Criteria $tagCriteria
$pgflexPolicy = New-AzDataProtectionBackupPolicy -SubscriptionId "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" -ResourceGroupName "resourceGroupName" -VaultName "vaultName" -Name "pgflex-policy" -Policy $defaultPol

Name                               Type
----                               ----
pgflex-policy       Microsoft.DataProtection/backupVaults/backupPolicies

Met de eerste opdracht wordt de standaardbeleidssjabloon voor AzureDatabaseForPGFlexServer ophaalt. Deze stappen kunnen ook worden gebruikt voor AzureDatabaseForMySQL. De tweede tot tiende opdracht definieert en werkt de gekluisde dagelijkse, maandelijkse levenscyclus en tagcriteria bij. Vervolgens definiƫren we een triggerobject met planning, stel dit in op elke wekelijkse maandag, dinsdagplanning. Met de laatste opdracht wordt het AzureDatabaseForPGFlexServer-beleid gemaakt.

Voorbeeld 7: Een kluisbeleid maken voor AzureKubernetesService

$defaultPol = Get-AzDataProtectionPolicyTemplate -DatasourceType AzureKubernetesService

$schDate = @(
(
    (Get-Date -Year 2024 -Month 10 -Day 02 -Hour 15 -Minute 30 -Second 0)
))
$trigger =  New-AzDataProtectionPolicyTriggerScheduleClientObject -ScheduleDays $schDate -IntervalType Daily -IntervalCount 1
Edit-AzDataProtectionPolicyTriggerClientObject -Schedule $trigger -Policy $defaultPol   

# Adding default retention rule below
$lifeCycleDefault = New-AzDataProtectionRetentionLifeCycleClientObject -SourceDataStore OperationalStore -SourceRetentionDurationType Days -SourceRetentionDurationCount 9
Edit-AzDataProtectionPolicyRetentionRuleClientObject -Policy $defaultPol -Name Default -LifeCycles $lifeCycleDefault -IsDefault $true

# Adding daily retention rule below
$lifeCycleDailyOperational = New-AzDataProtectionRetentionLifeCycleClientObject -SourceDataStore OperationalStore -SourceRetentionDurationType Days -SourceRetentionDurationCount 9 -TargetDataStore VaultStore -CopyOption ImmediateCopyOption
$lifeCycleDailyVaulted = New-AzDataProtectionRetentionLifeCycleClientObject -SourceDataStore VaultStore -SourceRetentionDurationType Days -SourceRetentionDurationCount 86
Edit-AzDataProtectionPolicyRetentionRuleClientObject -Policy $defaultPol -Name Daily -LifeCycles $lifeCycleDailyOperational, $lifeCycleDailyVaulted -IsDefault $false

$tagCriteriaDaily = New-AzDataProtectionPolicyTagCriteriaClientObject -AbsoluteCriteria FirstOfDay
Edit-AzDataProtectionPolicyTagClientObject -Policy $defaultPol -Name Daily -Criteria $tagCriteriaDaily
New-AzDataProtectionBackupPolicy -SubscriptionId "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" -ResourceGroupName "resourceGroupName" -VaultName "vaultName" -Name "newAKSPolicy" -Policy $defaultPol

Name              Type
----              ----
newAKSPolicy       Microsoft.DataProtection/backupVaults/backupPolicies

Met de eerste opdracht wordt de standaardbeleidssjabloon voor AzureKubernetesService ophaalt. Vervolgens maken we een aangepast planningsobject voor het back-upbeleid, eenmaal per dag vanaf $schDate. Vervolgens maken we een standaardretentieregel met operationele levenscyclus met 9 dagen retentie. Vervolgens maken we een dagelijkse bewaarregel met operationele levenscyclus met 9 dagen retentie en verplaatst naar gekluisde levenscyclus met ImmediateCopyOption en 86 dagen retentie. Vervolgens maken we een tagcriteria voor dagelijks beleid. Tagcriteria moeten worden toegevoegd voor elke aangepaste bewaarregel (automatisch toegevoegd voor standaardretentieregel). Met de laatste opdracht wordt het beleid gemaakt.

Parameters

-Confirm

U wordt gevraagd om bevestiging voordat u de cmdlet uitvoert.

Type:SwitchParameter
Aliassen:cf
Position:Named
Default value:None
Vereist:False
Pijplijninvoer accepteren:False
Jokertekens accepteren:False

-DefaultProfile

Type:PSObject
Aliassen:AzureRMContext, AzureCredential
Position:Named
Default value:None
Vereist:False
Pijplijninvoer accepteren:False
Jokertekens accepteren:False

-Name

Beleidsnaam

Type:String
Position:Named
Default value:None
Vereist:True
Pijplijninvoer accepteren:False
Jokertekens accepteren:False

-Policy

Policy Request Object To construct, zie de sectie NOTES voor POLICY-eigenschappen en het maken van een hash-tabel.

Type:IBackupPolicy
Position:Named
Default value:None
Vereist:True
Pijplijninvoer accepteren:False
Jokertekens accepteren:False

-ResourceGroupName

Naam van resourcegroep

Type:String
Position:Named
Default value:None
Vereist:True
Pijplijninvoer accepteren:False
Jokertekens accepteren:False

-SubscriptionId

Abonnements-id

Type:String
Position:Named
Default value:None
Vereist:False
Pijplijninvoer accepteren:False
Jokertekens accepteren:False

-VaultName

Kluisnaam

Type:String
Position:Named
Default value:None
Vereist:True
Pijplijninvoer accepteren:False
Jokertekens accepteren:False

-WhatIf

Toont wat er zou gebeuren als de cmdlet wordt uitgevoerd. De cmdlet wordt niet uitgevoerd.

Type:SwitchParameter
Aliassen:wi
Position:Named
Default value:None
Vereist:False
Pijplijninvoer accepteren:False
Jokertekens accepteren:False

Uitvoerwaarden

IBaseBackupPolicyResource