List AWS Backup Recovery Points Using AWS CLI

To see the number of recovery points for a specific resource you first need to get the resource ARN for that resource.

For example, if you want to check recovery points for an RDS database, you can retrieve it by running the below command:

aws rds describe-db-instances --region eu-west-2 --query 'DBInstances[].DBInstanceArn'

This will return the below output, containing the resource ARN’s for each RDS database in the specified region.

[
    "arn:aws:rds:eu-west-2:<account-id>:db:<db-name>",
    "arn:aws:rds:eu-west-2:<account-id>:db:<db-name>",
    "arn:aws:rds:eu-west-2:<account-id>:db:<db-name>",
    "arn:aws:rds:eu-west-2:<account-id>:db:<db-name>"
]

We can now use these to list all recovery points that exist for a resource we pick. If we tell AWS CLI to output in text and pipe the results to wc -l we will get a line count, and because text output through AWS CLI doesn’t include any column headers, the result we get back will be the actual number of recovery points that exist for the specified resource.

aws backup list-recovery-points-by-resource --resource-arn arn:aws:rds:eu-west-2:<account-id>:db:<db-name> --region eu-west-2 --output text | wc -l

As below:

jprice@DESKTOP-IVR4GBM [14:55:59] ~ $ > aws backup list-recovery-points-by-resource --resource-arn arn:aws:rds:eu-west-2:<account-id>:db:<db-name> --region eu-west-2 --output text | wc -l
4

About

I'm a technology professional who's been passionate about computers since my Grandad introduced me to an Intel 386 back in the 90s when I was a kid. Those moments inspired a passion within for technology, and I've been playing around with anything with a circuit board ever since. Whenever I have a moment you can probably find me working on something computer-related, and this is where I like to write about those moments.