Created
July 25, 2018 07:12
-
-
Save sumit-sampang-rai/487e3b947b1e896e216c73abc7edd1b3 to your computer and use it in GitHub Desktop.
Take snapshots of AWS instances
This file contains hidden or 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
PROFILE=srekcahrai;REGION=us-east-1;aws --profile=$PROFILE --region=$REGION ec2 describe-instances --filter Name='instance-state-name',Values='running' --output json | jq -r '.Reservations[].Instances[] | .InstanceId + "\t" + .BlockDeviceMappings[].Ebs.VolumeId' | while read instance_id volume_id;do aws --profile=$PROFILE --region=$REGION ec2 create-snapshot --volume-id="$volume_id" --description="$instance_id $volume_id $(date +"%F %T")";done; |
This file contains hidden or 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
PROFILE=srekcahrai;REGION=us-east-1;NAMETAG=srekcahrai;aws --profile=$PROFILE --region=$REGION ec2 describe-instances --filter Name='tag:Name',Values=$NAMETAG --output json| jq -r '.Reservations[].Instances[] | .InstanceId + "\t" + .BlockDeviceMappings[].Ebs.VolumeId' | while read instance_id volume_id;do aws --profile=$PROFILE --region=$REGION ec2 create-snapshot --volume-id="$volume_id" --description="$instance_id $volume_id $(date +"%F %T")";done; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment