Last active
August 29, 2015 14:05
-
-
Save alchemycs/72318782b775d58f45ad to your computer and use it in GitHub Desktop.
AWS Nightly Snapshot
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# We use this code from cron to automate nightly volume snapshots. | |
# In our case we have two volumes. | |
# | |
# | |
export EC2_KEYPAIR=MY-KEY-PAIR | |
export EC2_URL=https://ec2.ap-southeast-2.amazonaws.com | |
export AWS_ACCESS_KEY=accesskey | |
export AWS_SECRET_KEY=secretkey | |
export JAVA_HOME=/usr/lib/jvm/java-6-openjdk/ | |
sync | |
DATE=$(date +"%Y%m%d%H%M") | |
VOLUME1=vol-87f0a4d0 | |
VOLUME2=vol-acf0a4fb | |
DESCRIPTION1="ServerName-ROOT-Automated-Snapshot-"$DATE | |
DESCRIPTION2="ServerName-SITE-Automated-Snapshot-"$DATE | |
REGION=ap-southeast-2 | |
function create_snapshot() { | |
local volume=$1 | |
local description=$2 | |
echo "Creating snapshot $volume: $description" | |
echo -e "\tec2-create-snapshot $volume --region $region_name -d $description" | |
ec2-create-snapshot $volume --region $REGION -d $description | |
echo "Snapshot initiated, monitor progress with:" | |
echo -e "\tec2-describe-snapshots --filter tag-value=$description" | |
ec2-describe-snapshots --filter tag-value=$description | |
} | |
echo | |
create_snapshot $VOLUME1 $DESCRIPTION1 | |
echo | |
create_snapshot $VOLUME2 $DESCRIPTION2 | |
echo | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment