Musings on ZFS Backup strategies

George Kontostanos gkontos.mail at gmail.com
Thu Mar 7 11:23:14 UTC 2013


I have found that the use of mbuffer really speeds up the differential
transfer process:

#!/bin/sh
export PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:

pool="zroot"
destination="tank"
host="1.2.3.4"

today=`date +"$type-%Y-%m-%d"`
yesterday=`date -v -1d +"$type-%Y-%m-%d"`

# create today snapshot
snapshot_today="$pool@$today"
# look for a snapshot with this name
if zfs list -H -o name -t snapshot | sort | grep "$snapshot_today$" >
/dev/null; then
echo " snapshot, $snapshot_today, already exists"
exit 1
else
echo " taking todays snapshot, $snapshot_today" | sendmail root
zfs snapshot -r $snapshot_today
fi

# look for yesterday snapshot
snapshot_yesterday="$pool@$yesterday"

if zfs list -H -o name -t snapshot | sort | grep
"$snapshot_yesterday$" > /dev/null; then

echo " yesterday snapshot, $snapshot_yesterday, exists lets proceed
with backup"

zfs send -R -i $snapshot_yesterday $snapshot_today | mbuffer -q -v 0
-s 128k -m 1G | ssh root@$host "mbuffer -s 128k -m 1G | zfs receive
-Fd $destination" > /dev/null


echo " backup complete destroying yesterday snapshot" | sendmail root

zfs destroy -r $snapshot_yesterday
echo "Backup done" | sendmail root
exit 0
else
echo " missing yesterday snapshot aborting, $snapshot_yesterday"
exit 1
fi


-- 
George Kontostanos
---
http://www.aisecure.net


More information about the freebsd-stable mailing list