AWS Backup - Vault cannot be deleted? Use this script!

Michael Wittig – 11 Mar 2021

With AWS Backup, it is simple to create snapshots of EBS, EFS, and more. A retention period defines the number of recovery points stored within a backup vault. When removing a backup vault, you need to delete all recovery points first. Doing so is a cumbersome process. Read on to learn how to automate that task.

Vault cannot be deleted? Use this script!

Tried to delete a backup vault and got the following error message?

Backup vault cannot be deleted (contains 99 recovery points).

Check out the following script to avoid deleting recovery points manually.

Andreas and Michael Wittig

Hej, Andreas & Michael here!

We launched the cloudonaut blog in 2015. Since then, we have published 325 articles: small tips and tricks, best practices, and service reviews. We enjoy writing about all things AWS a lot.

Do you like our blog posts and podcast episodes? Have you learned something new? Consider supporting us create in-depth and independent AWS content. Please help us with a monthly or one-time payment through GitHub Sponsors.

Start supporting us today!

Make sure that to install the AWS CLI on your machine before you proceed.

The following script asks for the vault name you want to empty, fetches a list with the recovery points belonging to the backup vault, and deletes the recovery points.

#!/bin/bash

set -e

echo "Enter the name of the vault where all backups should be deleted."
read VAULT_NAME

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

The script saved me hundreds of manual steps. I hope you will enjoy it as well!

Michael Wittig

Michael Wittig

I'm an independent consultant, technical writer, and programming founder. All these activities have to do with AWS. I'm writing this blog and all other projects together with my brother Andreas.

In 2009, we joined the same company as software developers. Three years later, we were looking for a way to deploy our software—an online banking platform—in an agile way. We got excited about the possibilities in the cloud and the DevOps movement. It’s no wonder we ended up migrating the whole infrastructure of Tullius Walden Bank to AWS. This was a first in the finance industry, at least in Germany! Since 2015, we have accelerated the cloud journeys of startups, mid-sized companies, and enterprises. We have penned books like Amazon Web Services in Action and Rapid Docker on AWS, we regularly update our blog, and we are contributing to the Open Source community. Besides running a 2-headed consultancy, we are entrepreneurs building Software-as-a-Service products.

We are available for projects.

Feedback? Questions? Drop me a line: Email, Twitter, LinkedIn.

Briefcase icon
Hire me