Created
May 20, 2014 04:21
-
-
Save andys/4cf18b633c539ddd4b3c to your computer and use it in GitHub Desktop.
ZFS snapshot backup
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
#!/usr/bin/bash | |
for fs in dir1 dir2 dir3 ; do | |
srcfs="tank/$fs" | |
dstfs="backup/$fs" | |
oldsnap=`zfs list -H -r -t snapshot $dstfs |cut -f1 | grep '0000$' | sort | tail -1 | sed -e 's/.*@//'` | |
newsnap=`zfs list -H -r -t snapshot $srcfs |cut -f1 | grep '0000$' | sort | tail -1 | sed -e 's/.*@//'` | |
if [ x$newsnap != x ] ; then | |
if [ x$oldsnap != x ] ; then | |
echo "$fs: from fat/san/$fs@$oldsnap to $newsnap if needed..." | |
if [ $oldsnap != $newsnap ] ; then | |
zfs send -v -i $oldsnap fat/san/$fs@$newsnap | mbuffer -b 1 | zfs receive -d backup | |
fi | |
fi | |
fi | |
done | |
echo Done. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment