Created
September 9, 2008 23:23
-
-
Save kelp/9788 to your computer and use it in GitHub Desktop.
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 | |
# | |
# Backup this hosts MySQL databases using LVM snapshots. | |
# | |
if [ ! $1 ]; then | |
echo "snap-backup <snapshot size in GB>" | |
vgdisplay `hostname` | grep Free | |
exit 1 | |
fi | |
size=$1 | |
date > /thevoid/mysql/snapshot_date | |
hostname >> /thevoid/mysql/snapshot_date | |
mkdir -p /snapbackup | |
echo "Taking snapshot" | |
sudo lvcreate -L${size}G -s -n backups /dev/`hostname`/thevoid | |
sudo mount /dev/`hostname`/backups /snapbackup | |
echo "Your snapshot is now mounted at /snapbackup" | |
rm /thevoid/mysql/snapshot_date |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment