updating to rename to user_tag from auto_tag and use bash builtin for region evaluation. Also updated README.txt for ec2-automate-backup.

This commit is contained in:
Colin Johnson 2013-02-17 21:53:38 +00:00
parent d18b3c3f7d
commit ff06380942
4 changed files with 35 additions and 31 deletions

View File

@ -51,6 +51,6 @@ ec2-automate-backup requires one of the following two parameters be provided:
the file "ec2ab - IAM User Required Permissions.json" contains the IAM permissions required to run ec2-automate-backup.sh in with the least permissions required as of 2012-11-21. the file "ec2ab - IAM User Required Permissions.json" contains the IAM permissions required to run ec2-automate-backup.sh in with the least permissions required as of 2012-11-21.
- Author: Colin Johnson / colin@cloudavail.com - Author: Colin Johnson / colin@cloudavail.com
- Date: 2013-02-13 - Date: 2013-02-17
- Version 0.9 - Version 0.9 Beta
- License Type: GNU GENERAL PUBLIC LICENSE, Version 3 - License Type: GNU GENERAL PUBLIC LICENSE, Version 3

View File

@ -143,7 +143,7 @@ date_binary=""
#sets the "Name" tag set for a snapshot to false - using "Name" requires that ec2-create-tags be called in addition to ec2-create-snapshot #sets the "Name" tag set for a snapshot to false - using "Name" requires that ec2-create-tags be called in addition to ec2-create-snapshot
name_tag_create=false name_tag_create=false
#sets the auto_tagging feature to false - auto_tag creates tags on snapshots - by default each snapshot is tagged with volume_id and current_data timestamp #sets the user_tags feature to false - user_tag creates tags on snapshots - by default each snapshot is tagged with volume_id and current_data timestamp
user_tags=false user_tags=false
#sets the Purge Snapshot feature to false - this feature will eventually allow the removal of snapshots that have a "PurgeAfterFE" tag that is earlier than current date #sets the Purge Snapshot feature to false - this feature will eventually allow the removal of snapshots that have a "PurgeAfterFE" tag that is earlier than current date
purge_snapshots=false purge_snapshots=false

View File

@ -37,12 +37,12 @@ ec2-automate-backup requires one of the following two parameters be provided:
* To perform daily backup using cron and to load environment configuration with a "cron-primer" file: * To perform daily backup using cron and to load environment configuration with a "cron-primer" file:
- `0 0 * * 0 ec2-user /home/ec2-user/ec2-automate-backup.sh -c /home/ec2-user/cron-primer.sh -s tag -t "Backup=True"` - `0 0 * * 0 ec2-user /home/ec2-user/ec2-automate-backup.sh -c /home/ec2-user/cron-primer.sh -s tag -t "Backup=True"`
`-a` - the -a flag will tag snapshots with additional data so that snapshots can be more easily located. Currently the two auto tags created are Volume="ebs_volume" and Created="date" `-u` - the -u flag will tag snapshots with additional data so that snapshots can be more easily located. Currently the two user tags created are Volume="ebs_volume" and Created="date." These can be easily modified in code.
# Additional Information: # Additional Information:
the file "ec2ab - IAM User Required Permissions.json" contains the IAM permissions required to run ec2-automate-backup.sh in with the least permissions required as of 2012-11-21. the file "ec2ab - IAM User Required Permissions.json" contains the IAM permissions required to run ec2-automate-backup.sh in with the least permissions required as of 2012-11-21.
- Author: Colin Johnson / colin@cloudavail.com - Author: Colin Johnson / colin@cloudavail.com
- Date: 2013-01-27 - Date: 2013-02-17
- Version 0.1 - Version 0.9
- License Type: GNU GENERAL PUBLIC LICENSE, Version 3 - License Type: GNU GENERAL PUBLIC LICENSE, Version 3

View File

@ -1,7 +1,7 @@
#!/bin/bash - #!/bin/bash -
# Author: Colin Johnson / colin@cloudavail.com # Author: Colin Johnson / colin@cloudavail.com
# Date: 2013-01-27 # Date: 2013-02-13
# Version 0.1 # Version 0.9
# License Type: GNU GENERAL PUBLIC LICENSE, Version 3 # License Type: GNU GENERAL PUBLIC LICENSE, Version 3
# #
#confirms that executables required for succesful script execution are available #confirms that executables required for succesful script execution are available
@ -62,10 +62,10 @@ create_EBS_Snapshot_Tags()
snapshot_tags="$snapshot_tags --tag PurgeAfter=$purge_after_date --tag PurgeAllow=true" snapshot_tags="$snapshot_tags --tag PurgeAfter=$purge_after_date --tag PurgeAllow=true"
fi fi
#if $auto_tag is true, then append Volume=$ebs_selected and Created=$date_current to the variable $snapshot_tags #if $user_tags is true, then append Volume=$ebs_selected and Created=$current_date to the variable $snapshot_tags
if $auto_tag if $user_tags
then then
snapshot_tags="$snapshot_tags --tag Volume=${ebs_selected} --tag Created=$date_current" snapshot_tags="$snapshot_tags --tag Volume=${ebs_selected} --tag Created=$current_date"
fi fi
#if $snapshot_tags is not zero length then set the tag on the snapshot using ec2-create-tags #if $snapshot_tags is not zero length then set the tag on the snapshot using ec2-create-tags
@ -156,12 +156,13 @@ date_binary=""
#sets the "Name" tag set for a snapshot to false - using "Name" requires that ec2-create-tags be called in addition to ec2-create-snapshot #sets the "Name" tag set for a snapshot to false - using "Name" requires that ec2-create-tags be called in addition to ec2-create-snapshot
name_tag_create=false name_tag_create=false
#sets the auto_tagging feature to false - auto_tag creates tags on snapshots - by default each snapshot is tagged with volume_id and current_data timestamp #sets the user_tags feature to false - user_tag creates tags on snapshots - by default each snapshot is tagged with volume_id and current_data timestamp
auto_tag=false user_tags=false
#sets the Purge Snapshot feature to false - this feature will eventually allow the removal of snapshots that have a "PurgeAfter" tag that is earlier than current date #sets the Purge Snapshot feature to false - this feature will eventually allow the removal of snapshots that have a "PurgeAfter" tag that is earlier than current date
purge_snapshots=false purge_snapshots=false
#handles options processing #handles options processing
while getopts :s:c:r:v:t:k:pna opt; do while getopts :s:c:r:v:t:k:pnu opt
do
case $opt in case $opt in
s) selection_method="$OPTARG";; s) selection_method="$OPTARG";;
c) cron_primer="$OPTARG";; c) cron_primer="$OPTARG";;
@ -171,7 +172,7 @@ while getopts :s:c:r:v:t:k:pna opt; do
k) purge_after_days="$OPTARG";; k) purge_after_days="$OPTARG";;
n) name_tag_create=true;; n) name_tag_create=true;;
p) purge_snapshots=true;; p) purge_snapshots=true;;
a) auto_tag=true;; u) user_tags=true;;
*) echo "Error with Options Input. Cause of failure is most likely that an unsupported parameter was passed or a parameter was passed without a corresponding option." 1>&2 ; exit 64;; *) echo "Error with Options Input. Cause of failure is most likely that an unsupported parameter was passed or a parameter was passed without a corresponding option." 1>&2 ; exit 64;;
esac esac
done done
@ -185,11 +186,14 @@ if [[ -n $cron_primer ]]
fi fi
fi fi
if [ -z $region ]; then #if region is not set then:
if [ -z $EC2_REGION ]; then if [[ -z $region ]]
region="us-east-1" #if the environment variable $EC2_REGION is not set set to us-east-1
then if [[ -z $EC2_REGION ]]
#if both
then region="us-east-1"
else else
region="$EC2_REGION" region=$EC2_REGION
fi fi
fi fi