Created
February 21, 2012 18:22
-
-
Save WoZ/1877959 to your computer and use it in GitHub Desktop.
simple lvm backuper
This file contains hidden or 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 | |
# Dmitry Menshikov <[email protected]> | |
# http://menshikov.mp | |
PATH_TO_VG="/dev/mainvg" | |
BACKUP_PATH="/media/Reservation/.backups/zoidberg" | |
BACKUP_PATH=$BACKUP_PATH/`date +"%d_%m_%Y"` | |
if [[ $EUID -ne 0 ]]; then | |
echo "You must be a root user" 2>&1 | |
exit 1 | |
fi | |
if [ -d "$BACKUP_PATH" ]; then | |
echo "$BACKUP_PATH is not empty. Remove directory if you need to overwrite backups." | |
exit 1 | |
else | |
mkdir -p $BACKUP_PATH | |
fi | |
lvcreate -L1G -s -n rootsnapshot $PATH_TO_VG/root | |
lvcreate -L4G -s -n homesnapshot $PATH_TO_VG/home | |
lvcreate -L4G -s -n swapsnapshot $PATH_TO_VG/swap | |
dd if=$PATH_TO_VG/rootsnapshot of=$BACKUP_PATH/root.dd | |
lvremove -f $PATH_TO_VG/rootsnapshot | |
dd if=$PATH_TO_VG/homesnapshot of=$BACKUP_PATH/home.dd | |
lvremove -f $PATH_TO_VG/homesnapshot | |
dd if=$PATH_TO_VG/swapsnapshot of=$BACKUP_PATH/swap.dd | |
lvremove -f $PATH_TO_VG/swapsnapshot |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment