While loop to delete aws backup

Viewed 17

I am just using a bash script from my colleague which just here for deleting aws backup recovery point via while loop.

While below looks good, but i feel there might be a better version of it.

#!/bin/bash
#
aws backup list-recovery-points-by-backup-vault --backup-vault-name archiving-fsx-backup-vault --profile dev --no-cli-pager \
| jq -r '.RecoveryPoints[].RecoveryPointArn' \
| head -2 | while read barn;
do
  echo "$barn"
  aws backup delete-recovery-point --backup-vault-name archiving-fsx-backup-vault --recovery-point-arn "$barn" --profile dev;
  echo ""
done

This is working but just thing if there is a better way.

0 Answers
Related