Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add attached instance name and mount point in a snapshot tag #90

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions ec2-automate-backup/ec2-automate-backup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,15 @@ create_EBS_Snapshot_Tags() {
if $user_tags; then
snapshot_tags="$snapshot_tags --tag Volume=${ebs_selected} --tag Created=$current_date"
fi

instance_id=$(echo "$ebs_backup_list_complete"|grep ATTACH |grep ${ebs_selected} |awk '{print $3}')
volid_info=$(ec2-describe-instances --region $region --filter tag-key=Name "$instance_id")
if [ -n "$volid_info" ] ; then
mpoint=$(echo "$volid_info"|grep "$ebs_selected" |head -1|awk '{print $2}'|tr '/' '_')
instance_name=`echo "$volid_info"|grep Name |sed -e 's/.*Name\t\([^\b*]\)/\1/'`
snapshot_tags="$snapshot_tags --tag Volinfo=${mpoint}_${instance_name}"
fi

#if $snapshot_tags is not zero length then set the tag on the snapshot using ec2-create-tags
if [[ -n $snapshot_tags ]]; then
echo "Tagging Snapshot $ec2_snapshot_resource_id with the following Tags: $snapshot_tags"
Expand Down