After my moments of stupidity documented below I decided I'd fix the problem. I've coded up a script that will use zfs send and recv to replicate my home directory. At the moment it's manual, but I'll look into hooking into an automatic system:
#!/bin/bash
USER=fifors
HOST=stormspike.sfbay.sun.com
FS="rpool/export/home"
RS="rpool/zion-home-backup"
MAX_SNAP=15
NOW=`date +%Y%m%d%H%M%S`
INIT=0set -- `getopt i $*`
if [ $? != 0 ]
then
echo ${USAGE}
exit 2
fifor i in $*
do
case $i in
-i) echo Initialising Snapshot backup;
INIT=1;
shift;
continue;;
esac
doneALIVE=`ping ${HOST} 2>&1 | grep -c alive`
if [ ${ALIVE} ]
then
SNAPS=`zfs list -t snapshot |grep "${FS}@" | wc -l | tr -d " "`
echo Determine incremental
if [ "${INIT}" == "0" ]
then
ISNAP=`zfs list -t snapshot | grep rpool/export/home@ |tail -1 |cut -d " " -f 1`
fiecho "Creating zfs snapshot ${FS}@${NOW} ..."
zfs snapshot ${FS}@${NOW} > /dev/null 2> /tmp/error.$$
if [ $? -ne 0 ]
then
echo "Failed ($?)!"
cat /tmp/error.$$
rm /tmp/error.$$
exit 1
else
echo "Successfully created snapshot: ${FS}@${NOW} !"
fi
rm /tmp/error.$$
if [ ${SNAPS} -ge ${MAX_SNAP} ]
then
LAST=`zfs list -t snapshot | grep "${FS}@" | head -1 | awk '{ print $1}'`
echo "Destroying last snapshot: ${LAST}..."
zfs destroy ${LAST} > /dev/null 2> /tmp/error.$$
if [ $? -ne 0 ]
then
echo "Failed ($?)!"
cat /tmp/error.$$
rm /tmp/error.$$
exit 1
else
echo "Successfully destroyed snapshot: ${LAST} !"
fi
rm /tmp/error.$$
fiif [ "${INIT}" == "1" ]
then
echo "Initialising the zfs replication of ${FS}..."
zfs send ${FS}@${NOW} | ssh ${USER}@${HOST} pfexec /sbin/zfs recv ${RS}@${NOW}
else
echo "Initiate the zfs send of ${FS}@${NOW} to ${RS}@${NOW}..."
zfs send -i ${ISNAP} ${FS}@${NOW} | ssh ${USER}@${HOST} pfexec /sbin/zfs recv -F ${RS}@${NOW}
fiif [ $? -ne 0 ]
then
echo "Failed ($?)!"
exit 1
else
echo "Successfully synced snapshot: ${FS}@${NOW} and ${RS}@${NOW} !"
fi
else
echo "Cannot connect to ${HOST}"
fi
It's pretty simple really, just relies on the underlying aspects of ZFS to make it all ok.
Grr.. it looks like html destroys the format... I'll fix that later.
