From ca1c2358cc404d6f3c24bc869e33c42c6c2f1f06 Mon Sep 17 00:00:00 2001 From: Phillip Jackson Date: Thu, 24 Apr 2014 15:47:24 -0400 Subject: [PATCH 1/2] Adding ability to label a backup snapshot --- ec2-automate-backup/ec2-automate-backup-awscli.sh | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/ec2-automate-backup/ec2-automate-backup-awscli.sh b/ec2-automate-backup/ec2-automate-backup-awscli.sh index 94e7b64..e30661f 100755 --- a/ec2-automate-backup/ec2-automate-backup-awscli.sh +++ b/ec2-automate-backup/ec2-automate-backup-awscli.sh @@ -75,6 +75,11 @@ create_EBS_Snapshot_Tags() snapshot_tags="$snapshot_tags Key=PurgeAfterFE,Value=$purge_after_date_fe Key=PurgeAllow,Value=true" fi + if [[ -n $label ]] + then + snapshot_tags="$snapshot_tags Key=Name,Value=$label" + fi + #if $user_tags is true, then append Volume=$ebs_selected and Created=$current_date to the variable $snapshot_tags if $user_tags then @@ -166,9 +171,10 @@ user_tags=false purge_snapshots=false #handles options processing -while getopts :s:c:r:v:t:k:pnhu opt +while getopts :l:s:c:r:v:t:k:pnhu opt do case $opt in + l) label="$OPTARG";; s) selection_method="$OPTARG";; c) cron_primer="$OPTARG";; r) region="$OPTARG";; From cf77a53be87957b6982a25b21a7487b63fcfed16 Mon Sep 17 00:00:00 2001 From: Phillip Jackson Date: Thu, 24 Apr 2014 15:52:48 -0400 Subject: [PATCH 2/2] Add documentation --- ec2-automate-backup/README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ec2-automate-backup/README.md b/ec2-automate-backup/README.md index 2560490..08789f8 100644 --- a/ec2-automate-backup/README.md +++ b/ec2-automate-backup/README.md @@ -30,6 +30,8 @@ ec2-automate-backup requires one of the following two parameters be provided: `-c ` - running with the -c option and a providing a file will cause ec2-automate-backup to source a file for environmental configuration - ideal for running ec2-automate-backup under cron. An example cron primer file is located in the "Resources" directory and is called cron-primer.sh. +`-l` - label a snapshot "Name" tag with a user-defined value + `-n` - tag snapshots "Name" tag as well as description `-h` - tag snapshots "InitiatingHost" tag to specify which host ran the script @@ -45,6 +47,8 @@ ec2-automate-backup requires one of the following two parameters be provided: - `0 0 1 * * ec2-user /home/ec2-user/ec2-automate-backup.sh -s tag -t "Backup-Monthly=true"` * 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"` +* To perform a daily backup with cron and loading environment configuration with a user-defined label: + - `0 0 * * 0 ec2-user /home/ec2-user/ec2-automate-backup.sh -c /home/ec2-user/cron-primer.sh -s tag -t "Backup=True" -l "Production Site Backup"` `-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.