From 922fcab3a77608dea19b23df06d1c1e750ed2ead Mon Sep 17 00:00:00 2001 From: Colin Johnson Date: Sun, 2 Nov 2014 18:31:39 +0000 Subject: [PATCH] resolve issues with getting snapshot result --- ec2-automate-backup/Resources/ec2ab-test-plan.txt | 8 ++++---- ec2-automate-backup/ec2-automate-backup-awscli.sh | 4 +--- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/ec2-automate-backup/Resources/ec2ab-test-plan.txt b/ec2-automate-backup/Resources/ec2ab-test-plan.txt index c3f35bf..ab7c7a2 100644 --- a/ec2-automate-backup/Resources/ec2ab-test-plan.txt +++ b/ec2-automate-backup/Resources/ec2ab-test-plan.txt @@ -1,15 +1,15 @@ -ec2ab_exec="../ec2-automate-backup-awscli.sh" +ec2ab_exec="./ec2-automate-backup-awscli.sh" #create two volumes -volume_1=$(ec2-create-volume --size 5 GB --availability-zone us-east-1c --type io1 --iops 100) -volume_2=$(ec2-create-volume --size 2 GB --availability-zone us-east-1c) +volume_1=$(ec2-create-volume --size 5 GB --availability-zone us-east-1b --type io1 --iops 100) +volume_2=$(ec2-create-volume --size 2 GB --availability-zone us-east-1b) #get volume id of both volumes volume_1_id=$(echo "$volume_1" | cut -f 2) volume_2_id=$(echo "$volume_2" | cut -f 2) #tag volume_1 with Backup=true -ec2-create-tags $volume_1_id --tag Backup=true +aws ec2 create-tags --resources $volume_1_id --tag Key=Backup,Value=true #test backing up only volume with tag Backup=true # if testing ec2-automate-backup.sh diff --git a/ec2-automate-backup/ec2-automate-backup-awscli.sh b/ec2-automate-backup/ec2-automate-backup-awscli.sh index 41c6252..52fe606 100755 --- a/ec2-automate-backup/ec2-automate-backup-awscli.sh +++ b/ec2-automate-backup/ec2-automate-backup-awscli.sh @@ -204,11 +204,9 @@ get_EBS_List #the loop below is called once for each volume in $ebs_backup_list - the currently selected EBS volume is passed in as "ebs_selected" for ebs_selected in $ebs_backup_list; do ec2_snapshot_description="ec2ab_${ebs_selected}_$current_date" - ec2_create_snapshot_result=$(aws ec2 create-snapshot --region $region --description $ec2_snapshot_description --volume-id $ebs_selected --output text 2>&1) + ec2_snapshot_resource_id=$(aws ec2 create-snapshot --region $region --description $ec2_snapshot_description --volume-id $ebs_selected --output text --query SnapshotId 2>&1) if [[ $? != 0 ]]; then echo -e "An error occurred when running ec2-create-snapshot. The error returned is below:\n$ec2_create_snapshot_result" 1>&2 ; exit 70 - else - ec2_snapshot_resource_id=$(echo "$ec2_create_snapshot_result" | cut -f 4) fi create_EBS_Snapshot_Tags done