Last active
March 31, 2016 15:37
-
-
Save mungi/7ddb3eafaecbf5fee404fc21c623e67c to your computer and use it in GitHub Desktop.
This file contains 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 | |
EC2_AVAIL_ZONE=`curl -s http://169.254.169.254/latest/meta-data/placement/availability-zone` | |
export AWS_DEFAULT_REGION="`echo \"$EC2_AVAIL_ZONE\" | sed -e 's:\([0-9][0-9]*\)[a-z]*\$:\\1:'`" | |
if [ $# -eq 0 ] | |
then | |
echo "Need Filter Value eg. $0 web" | |
else | |
ec2list | grep $1 | awk '{print $3,$1}' | while read param;do | |
arr=($param) | |
aws ec2 create-image --no-reboot --instance-id ${arr[0]} --name Backup_$(date +%y%m%d-%H%M)_${arr[1]}_${arr[0]} | |
done | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment