1

I'm using AWS Backup to create snapshots of my production server. My current backup plan has infinite retention and that ran me into gigabytes of storage.

What would be the best way to fix that? I saw I can't remove the backups in bulk (can only select and remove each single backup, but I have 100s).

Is it possible to modify the backup rule so that it removes the previous backups? Or is there a way to select and remove all the backups done by AWS Backup?

1

Coincidentally I had to do something very similar yesterday. This is the script I used:

#!/bin/bash -e

VAULT_NAME=...   # put your Backup Vault name here

for ARN in $(aws backup list-recovery-points-by-backup-vault --backup-vault-name "${​​​​​​​VAULT_NAME}​​​​​​​" --query 'RecoveryPoints[].RecoveryPointArn' --output text); do
  echo "deleting ${​​​​​​​ARN}​​​​​​​ ..."
  aws backup delete-recovery-point --backup-vault-name "${​​​​​​​VAULT_NAME}​​​​​​​" --recovery-point-arn "${​​​​​​​ARN}​​​​​​​"
done

You can also add --by-created-before to delete the old backups only.

Hope that helps :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.