2014-11-02 18:31:39 +00:00
ec2ab_exec="./ec2-automate-backup-awscli.sh"
2014-04-12 23:06:26 +00:00
2013-02-17 20:20:35 +00:00
#create two volumes
2014-11-02 18:31:39 +00:00
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)
2014-04-12 23:06:26 +00:00
2013-02-17 20:20:35 +00:00
#get volume id of both volumes
2014-04-20 00:34:18 +00:00
volume_1_id=$(echo "$volume_1" | cut -f 2)
volume_2_id=$(echo "$volume_2" | cut -f 2)
2014-04-12 23:06:26 +00:00
2013-02-17 20:20:35 +00:00
#tag volume_1 with Backup=true
2014-11-02 18:31:39 +00:00
aws ec2 create-tags --resources $volume_1_id --tag Key=Backup,Value=true
2014-04-12 23:06:26 +00:00
2013-02-17 20:20:35 +00:00
#test backing up only volume with tag Backup=true
2014-04-12 23:06:26 +00:00
# if testing ec2-automate-backup.sh
2013-02-17 20:20:35 +00:00
$ec2ab_exec -s tag -t Backup=true
2014-04-12 23:06:26 +00:00
# if testing ec2-automate-backup-awscli.sh
$ec2ab_exec -s tag -t Backup,Values=true
2013-02-17 20:20:35 +00:00
#expected result - snapshot only taken of volume_1
2014-04-12 23:06:26 +00:00
2013-02-17 20:20:35 +00:00
#test backing up only EBS volume with IDs "x" and "y"
$ec2ab_exec -v "$volume_1_id $volume_2_id"
#expected result - snapshot only taken of volume_1 and volume_2
2014-04-12 23:06:26 +00:00
2013-02-17 20:20:35 +00:00
#test backing up only EBS volume with IDs "x" and "y" and tagging them with "name"
$ec2ab_exec -v "$volume_1_id $volume_2_id" -n
#expected result - snapshot only taken of volume_1 and volume_2 each with tag "name" set to ec2ab_$volume_id_$current_date
2014-04-12 23:06:26 +00:00
2013-02-17 20:20:35 +00:00
#test backing up only EBS volume with IDs "x" and "y" and tagging them with "user tags"
$ec2ab_exec -v "$volume_1_id $volume_2_id" -u
#expected result - snapshot only taken of volume_1 and volume_2 each with tag "user tags" set to Volume=$ebs_selected and Created=$current_date
2014-04-12 23:06:26 +00:00
2013-02-17 20:20:35 +00:00
#test backing up only EBS volume with IDs "x" and "y" and tagging them with a tag "PurgeAfterFE=$current_date+604800"
$ec2ab_exec -v "$volume_1_id $volume_2_id" -k 7
2014-04-20 00:34:18 +00:00
echo "PurgeAfterFE=$(date -v +604800S -u +%s)"
echo "PurgeAfterFE=$(date -d +604800sec -u +%s)"
2013-02-17 20:20:35 +00:00
#expected result - snapshot taken of volume_1 and volume_2 each with tags "PurgeAfterFE=$current_date+604800" and "PurgeAllow=true"
2014-04-12 23:06:26 +00:00
2013-02-17 20:20:35 +00:00
#test backing up only EBS volume with IDs "x" and "y" and tagging them with a tag "PurgeAfterFE=$current_date+604800"
$ec2ab_exec -v "$volume_1_id $volume_2_id" -k 7 -n
2014-04-20 00:34:18 +00:00
echo "PurgeAfterFE=$(date -v+604800S -u +%s)"
echo "PurgeAfterFE=$(date -d +604800sec -u +%s)"
2013-02-17 20:20:35 +00:00
#expected result - snapshot taken of volume_1 and volume_2 each with tag "name" set to ec2ab_$volume_id_$date_current a with a tag "PurgeAfterFE=$current_date+604800"
2014-04-12 23:06:26 +00:00
2013-02-17 20:20:35 +00:00
#test backing up only EBS volume with IDs "x" and "y" and tagging them with a tag "PurgeAfterFE=$current_date+3600"
$ec2ab_exec -v "$volume_1_id $volume_2_id" -k 1h -n
2014-04-20 00:34:18 +00:00
echo "PurgeAfterFE=$(date -v+3600S -u +%s)"
echo "PurgeAfterFE=$(date -d +3600sec -u +%s)"
2013-02-17 20:20:35 +00:00
#expected result - snapshot taken of volume_1 and volume_2 each with tag "name" set to ec2ab_$volume_id_$date_current a with a tag "PurgeAfterFE=$current_date+3600"
2014-04-12 23:06:26 +00:00
2013-02-17 20:20:35 +00:00
#test backing up only EBS volume with IDs "x" and "y" and tagging them with a tag "PurgeAfterFE=$current_date+3600"
$ec2ab_exec -v "$volume_1_id $volume_2_id" -k 30m -n
2014-04-20 00:34:18 +00:00
echo "PurgeAfterFE=$(date -v+1800S -u +%s)"
echo "PurgeAfterFE=$(date -d +1800sec -u +%s)"
2013-02-17 20:20:35 +00:00
#expected result - snapshot taken of volume_1 and volume_2 each with tag "name" set to ec2ab_$volume_id_$date_current a with a tag "PurgeAfterFE=$current_date+3600"
2014-04-12 23:06:26 +00:00
2013-02-17 20:20:35 +00:00
#test backing up only EBS volume with IDs "x" and "y" and tagging them with a tag "PurgeAfterFE=$current_date+60" and purging snapshots
$ec2ab_exec -v "$volume_1_id $volume_2_id" -k 1m -n -p
2014-04-20 00:34:18 +00:00
echo "PurgeAfterFE=$(date -v+60S -u +%s)"
echo "PurgeAfterFE=$(date -d +60sec -u +%s)"
2013-02-17 20:20:35 +00:00
#expected result - snapshot taken of volume_1 and volume_2 each with tag "name" set to ec2ab_$volume_id_$date_current a with a tag "PurgeAfterFE=$current_date+60" and if run twice after 60 seconds, volumes purged