Skip to content

Instantly share code, notes, and snippets.

@MatthewJDavis
Created April 6, 2019 00:30
Show Gist options
  • Select an option

  • Save MatthewJDavis/8d37b23e6d8bf4a5c0f9be7a8d9e99bc to your computer and use it in GitHub Desktop.

Select an option

Save MatthewJDavis/8d37b23e6d8bf4a5c0f9be7a8d9e99bc to your computer and use it in GitHub Desktop.
Create a new backup plan selection based on a tag value
# Resource selection https://docs.aws.amazon.com/sdkfornet/v3/apidocs/index.html?page=Backup/TBackupCondition.html&tocid=Amazon_Backup_Model_Condition
$BackupSelectionName = '4AM-7-Day-Retention-Tag'
$IAMRoleARN = (Get-IAMRole -RoleName AWSBackupDefaultServiceRole).arn # using the default created role here
$BackupCondition = New-Object -TypeName Amazon.Backup.Model.Condition
$BackupCondition.ConditionKey = 'BackupPolicy'
$BackupCondition.ConditionValue = '4AM-7-Day-Retention'
$BackupCondition.ConditionType = 'STRINGEQUALS'
New-BAKBackupSelection -BackupPlanId $BackupPlan.BackupPlanId -BackupSelection_SelectionName $BackupSelectionName -BackupSelection_ListOfTag $BackupCondition -BackupSelection_IamRoleArn $IAMRoleARN
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment