Skip to content

Instantly share code, notes, and snippets.

@mikejk8s
Created November 2, 2017 16:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mikejk8s/76f5b947d692243b093e9d608ab5cc47 to your computer and use it in GitHub Desktop.
Save mikejk8s/76f5b947d692243b093e9d608ab5cc47 to your computer and use it in GitHub Desktop.
Google Snapshot Delete
#!/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