CaseyLabs / aws-ec2-ebs-automatic-snapshot-bash

Bash script for Automatic EBS Snapshots and Cleanup on Amazon Web Services (AWS). Created by CaseyLabs.
http://www.caseylabs.com
GNU General Public License v2.0
285 stars 193 forks source link

Removed truncation which removes timezone info from snapshot StartTime (needed for correct date +%s conversion) #28

Closed jtaala closed 6 years ago

jtaala commented 6 years ago

Removed "awk -F "T" '{printf "%s\n", $1}'" from snapshot_date variable. This truncates the returned snapshot StartTime - but also removes the timezone information, which is needed for correct 'snapshot_date_in_seconds' date conversion.

More explicitly: the problem here is that the time component also includes the timezone marker ("Z" for Zulu). This means that the following 'date' call interprets the returned StartTime as the servers' local time... which is likely incorrect (unless server is set to UTC).

Note, 'date --date ....' can already interpret the time string returned from AWS as is (it's in ISO format) - so not sure why we might need to truncate all characters after "T"...