Delete Old EBS Snapshots Command

I needed the ability to clean up old Amazon Web Services EBS snapshots. I didn’t want to deal with providing credentials beyond what are already set up. Here’s an easy […]

I needed the ability to clean up old Amazon Web Services EBS snapshots. I didn’t want to deal with providing credentials beyond what are already set up. Here’s an easy command to make this happen.

user@computer:$ ec2-describe-snapshots | sort -r -k 5 | sed 1,6d | awk '{print "Deleting snapshot: " $2}; system("ec2-delete-snapshot " $2)'

Change the second value in the sed command from 6 to however many snapshots you wish to keep. It will delete all others.

Share
Tags: , ,

About ipaul

My name is Paul Hassinger, the founder of ipaul.com. I have been an avid user of computers since a child. I started when I was about 10 years old working on an Atari computer. Since then, I grew and have had exposure to all types of technologies. I started using FIDONet on a BBS as a child and grew to the Internet. My first graphical world wide web experience was in 1993 using Mosaic. Over time I've worked with both small and large computing systems even maintaining systems serving millions of users on some of the largest social networking sites. I hope to use this blog to capture what I've learned over the years and what I do in my daily life so that others and myself may find the information useful.