Created
August 20, 2013 07:18
-
-
Save maakuth/6278078 to your computer and use it in GitHub Desktop.
Neat way to getting consistent backups of stuff by utilizing LVM snapshots. In my setup /backuptarget is an USB hard drive, but it could be sshfs, smb or nfs share just as well.
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/sh | |
. /etc/environment | |
lvcreate -l90%FREE -s -n rootsnap /dev/host/root | |
#XFS specific: Mounting ignoring uuid because the original volume has same uuid | |
mount -o ro,nouuid /dev/host/rootsnap /mnt/rootsnap | |
mount /backuptarget | |
#Purge history | |
rdiff-backup --remove-older-than 1Y /backuptarget/stuff | |
#Actual backup | |
rdiff-backup --exclude /mnt/rootsnap/stuff/NotInNeedOfBackingUp /mnt/rootsnap/stuff /backuptarget/stuff | |
umount /backuptarget | |
umount /mnt/rootsnap | |
lvremove -f /dev/host/rootsnap |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment