Skip to content

Instantly share code, notes, and snippets.

@cocoy
Created December 13, 2010 08:44
Show Gist options
  • Save cocoy/738803 to your computer and use it in GitHub Desktop.
Save cocoy/738803 to your computer and use it in GitHub Desktop.
0 0 * * * /vol/conf/snapshot.sh >> /mnt/backup_ebs.log 2>&1
0 2 * * * /vol/conf/manage_snaphost.sh >> /mnt/backup_ebs.log 2>&1
#!/bin/sh
# Filename: manage_snapshot.sh
#
if [ -f /mnt/VOLUME_USED ]; then
VOLUME=`cat /mnt/VOLUME_USED`
/usr/sbin/aws dsnap | grep $VOLUME | sort -r -k 5 | sed 1,10d | awk '{print "Deleting snapshot: " $2 " Dated: " $8}; system("/usr/sbin/aws delsnap " $2)' >> /mnt/backup_ebs.log
fi
#!/bin/bash
# Filename: snaphost.sh
#
# Run as inside cron.
EBS_DIR=/vol
PATH=$PATH:$HOME/bin:$EC2_HOME/bin:/usr/sbin
if [ -f /mnt/VOLUME_USED ]; then
VOLUME=`cat /mnt/VOLUME_USED`
echo "Date: $(date)"
/usr/bin/ec2-consistent-snapshot --description "$VOLUME $(date +\%F-\%T)" --mysql --xfs-filesystem $EBS_DIR $VOLUME
/usr/sbin/xfs_freeze -u $EBS_DIR
fi
@cocoy
Copy link
Author

cocoy commented Feb 9, 2011

aws dvol | grep | grep device=/dev/sd[klmn] | awk '{ print $2}'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment