cloudavail / aws-missing-tools

tools for managing AWS resources including EC2, EBS, RDS, IAM, CloudFormation and Route53.
1.34k stars 406 forks source link

ec2-automate-backup.sh doesnt delete snapshots #122

Closed modasir closed 8 years ago

modasir commented 8 years ago

Hi,

We are running and this doesnt delete anything older than one day what are we missing ?

We got the script from https://github.com/colinbjohnson/aws-missing-tools/tree/master/ec2-automate-backup

ec2-automate-backup.sh -r "us-west-2" -s tag -t "Backup,Values=true" -k 1 -h > /data/scripts/ec2-automate-backup.log

modasir commented 8 years ago

Snapshots taken by ec2-automate-backup will be eligible for purging after the following date (the purge after date given in seconds from epoch): 1458239434. Tagging Snapshot snap-b9fffbe6 with the following Tags: Key=CreatedBy,Value=ec2-automate-backup Key=InitiatingHost,Value='ip-10-220-5-100' Key=PurgeAfterFE,Value=1458239434 Key=PurgeAllow,Value=true Tagging Snapshot snap-8c457dc9 with the following Tags: Key=CreatedBy,Value=ec2-automate-backup Key=InitiatingHost,Value='ip-10-220-5-100' Key=PurgeAfterFE,Value=1458239434 Key=PurgeAllow,Value=true

modasir commented 8 years ago

Not sure what we are missing to purge...We even tried the following

\ ./ec2-automate-backup -r "us-west-2" -s tag -t "Backup,Values=true" -k 1 -p -h > /data/scripts/ec2-automate-backup.log **

jppunnett commented 8 years ago

Your first sample script did not contain the -p flag, but I see that you included it in second sample script. What does the ec2-automate-backup.log contain after you run the second script?

modasir commented 8 years ago

Thanks for the response.

If you run the script this way it seems to work via cron.

/data/scripts/ec2-automate-backup.sh -r "us-west-2" -s tag -t "Backup,Values=true" -k 5 -p -h > /data/scripts/ec2-automate-backup.log

This deleted shapshots from March 24th. I do have snapshots that are from March 8th - March 16th that didn't get deleted. Any ideas

The following are the tags for the ones that didn't get deleted. CreatedBy ec2-automate-backup
PurgeAfterFE 1460166301
PurgeAllow true
################################################################################## Here is the log output.

Snapshots taken by ec2-automate-backup.sh will be eligible for purging after the following date (the purge after date given in seconds from epoch): 1459706089. Tagging Snapshot snap-a152e3ff with the following Tags: Key=CreatedBy,Value=ec2-automate-backup Key=InitiatingHost,Value='ip-10-220-5-100' Key=PurgeAfterFE,Value=1459706089 Key=PurgeAllow,Value=true Tagging Snapshot snap-cfdf7d95 with the following Tags: Key=CreatedBy,Value=ec2-automate-backup Key=InitiatingHost,Value='ip-10-220-5-100' Key=PurgeAfterFE,Value=1459706089 Key=PurgeAllow,Value=true Snapshot Purging is Starting Now. Snapshot "snap-248a717c" with the PurgeAfterFE date of "1459238401" will be deleted. Snapshot "snap-607c223f" with the PurgeAfterFE date of "1459238401" will be deleted.

jppunnett commented 8 years ago

Glad you got things working.

For the snapshots that were not deleted, they won't be deleted until after 9 April 2016. The value 1460166301 assigned to PurgeAfterFE is a UNIX time stamp and it represents 9 April 2016.

modasir commented 8 years ago

Thanks!