Skip to content

Instantly share code, notes, and snippets.

@cocoy
Created June 30, 2011 05:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cocoy/1055668 to your computer and use it in GitHub Desktop.
Save cocoy/1055668 to your computer and use it in GitHub Desktop.
#!/bin/bash
#
# Filaneme: ebs_backup
#
VOLUMES=''
EBS_DIR=/nfs-raid
ISMOUNTED=$(df -la | grep -c $EBS_DIR)
if [ $ISMOUNTED -gt 0 ];then
echo "/dev/md0 is mounted"
# check volumes
if [ -f /home/ubuntu/VOLUME_USED ]; then
VOLUMES=$(cat /home/ubuntu/VOLUME_USED)
echo "Snapshotting.."
# snapshot EBS volumes
ec2-consistent-snapshot \
--aws-access-key-id ACCESS_KEY \
--aws-secret-access-key SECRET_KEY \
--freeze-filesystem /nfs-raid \
--region us-west-1 \
--description "NFS RAID snapshot $(date +'%Y-%m-%d %H:%M:%S')" \
$VOLUMES
else
echo "/home/ubuntu/VOLUME_USED file not found"
exit 1
fi
else
echo "Volume $EBS_DIR not mounted"
exit 1
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment