resolve issues with getting snapshot result

This commit is contained in:
Colin Johnson 2014-11-02 18:31:39 +00:00
parent 3f0ec2a00d
commit 922fcab3a7
2 changed files with 5 additions and 7 deletions

View File

@ -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

View File

@ -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