Skip to content

Instantly share code, notes, and snippets.

@hatchcanon
hatchcanon / aws-backup-vault-purge.sh
Last active January 31, 2021 20:02
Removes all recovery points from a specific time frame inside a AWS Backup vault
#!/bin/bash
VAULT_NAME=""
echo "Enter the name of the vault where all backups should be deleted"
read -t 10 VAULT_NAME || exit
# be sure to change the by-created-before and by-created-after to your liking
for ARN in $(aws backup list-recovery-points-by-backup-vault --backup-vault-name "${VAULT_NAME}" --by-created-before "2021-01-28T21:28:00/-0600" --by-created-after "2021-01-28T21:26:00/-0600" --query 'RecoveryPoints[].RecoveryPointArn' --output text --region us-east-1); do
echo "deleting ${ARN} ..."
aws backup delete-recovery-point --region us-east-1 --backup-vault-name "${VAULT_NAME}" --recovery-point-arn "${ARN}"