-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathec2-elastic-backup
executable file
·43 lines (35 loc) · 1.23 KB
/
ec2-elastic-backup
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/bin/bash
#
# install http://code.google.com/p/amazon-simpledb-cli/
# and http://developer.amazonwebservices.com/connect/entry.jspa?externalID=1136
# WARNING: make sure to install the required packages of the second as well
export JAVA_HOME="location to your java home"
export EC2_PRIVATE_KEY="location to your private key file"
export EC2_CERT="location to your certificate"
export EC2_HOME="location to your ec2 home"
export AWS_ACCESS_KEY_ID="your aws access key id"
export AWS_SECRET_ACCESS_KEY="your aws secret access key"
PATH=$PATH:$HOME/bin:$EC2_HOME/bin:/usr/local/bin
region="eu-west-1"
# if called with a parameter that is accepted by 'data --date'
# it creates a date based on that value. if it is empty we take
# a default expiration of 24 hours
offset=$1
if [ "${offset}" == "" ]
then
offset="24 hours"
fi
expiration=$(date -u --date="${offset}" +"%Y-%m-%d %H:%M:%S")
if [ "$expiration" == "" ]
then
exit 0
fi
vols=( "vol-44c3262d" )
mountpoints=( "/var/www" )
for ((i = 0; i < ${#vols[@]}; i++))
do
xfs_freeze -f ${mountpoints[i]}
snapshot=($(ec2-create-snapshot ${vols[i]} --region $region))
xfs_freeze -u ${mountpoints[i]}
/usr/local/bin/simpledb put snapshot ${snapshot[1]} expires="${expiration}"
done