Created
November 2, 2017 16:34
-
-
Save mikejk8s/76f5b947d692243b093e9d608ab5cc47 to your computer and use it in GitHub Desktop.
Google Snapshot Delete
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# snapshots are incremental and dont need to be deleted, deleting snapshots will merge snapshots, so deleting doesn't loose anything | |
# having too many snapshots is unwiedly so this script deletes them after 60 days | |
# | |
gcloud compute snapshots list --filter="creationTimestamp<$(date -d "-2 days" "+%Y-%m-%d")" --regexp "(gcs.*)" --uri | while read SNAPSHOT_URI; do | |
gcloud compute snapshots delete $SNAPSHOT_URI --quiet | |
done | |
# |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment