Batch delete CloudNativePG backups
This script is very destructive. Do not run unless you fully accept the risk.
Problem statement
I completely forgot that my snapshot-based CloudNativePG backups were piling up. To get rid of them I needed a script which I can run periodically to clean things up.
Public apology: The initially published script was copy/pasta from the initial AI output instead of the manually completed script. Apologies to those who wasted their time using a defunct piece of code.
The (new) script
Generated with AI but tested and hosted here:
https://github.com/Kaurin/cnpg-backups-cleanup
Notes:
At the time of writing this, retention policy for CloudNativePG backups are not implemented for Volume-Snapshot-based backups.