On 09/07/09 07:29 PM, David Dyer-Bennet wrote:

Is anybody doing this [zfs send/recv] routinely now on 2009-6
OpenSolaris, and if so can I see your commands?

Wouldn't a simple recursive send/recv work in your case? I
imagine all kinds of folks are doing it already. The only problem
with it, AFAIK, is when a new fs is created locally without also
being created on the backup disk (unless this now works with
zfs > V3). The following works with snv103. If it works there, it
should work with 2009-6. The script method may have the advantage
of not destroying file systems on the backup that don't exist
on the source, but I have not tested that.

ZFS send/recv is pretty cool, but at least with older versions, it
takes some tweaking to get right. Rather than send to a local drive,
I'm sending to a live remote system, which is some ways is more
complicated since there might be things like /opt and xxx/swap
that you might not want to even send. Finally, at least with ZFS
version 3, an incremental send of a filesystem that doesn't exist
on the far side doesn't work either, so one needs to test for that.

Given this, a simple send of a recursive snapshot AFAIK isn't going to
work. I am no bash expert, so this script probably can do with lots
of improvements, but it seems to do what I need it to do. You would
have to extensively modify it for your local needs; you would have
to remove the "ssh backup" and fix it to receive to your local disk. I
include it here in response to your request in the hope that it
might be useful. Note, as written, it will create space/swap but it
won't send updates.

The pool I'm backing up is called "space" and the target host is called
"backup", an alias in /etc/hosts. When the machines switch roles, I
edit both /etc/hosts so the stream can go the other way. This script
probably won't work for rpools; there is lots of documentation about
that in previous posts to this list.

My solution to the rpool problem is to receive it locally to an
alternate root and then send that, but this works here if the
rpool isn't your only pool, of course.

If any zfs/bash gurus out there can suggest improvements, they
would be much appreciated, especially ways to deal with the /opt
problem (which probably relates to the general rpool question).
Currently the /opts for each host are set mountpoint=legacy,
but that is not a great solution :-(.

Cheers -- Frank

#!/bin/bash
P=`cat cur_snap`
rm -f cur_snap
T=`date "+%Y-%m-%d:%H:%M:%S"`
echo $T > cur_snap
echo snapping to sp...@$t
zfs snapshot -r sp...@$t
echo snapshot done
for FS in `zfs list -H | cut -f 1`
do
RFS=`ssh backup "zfs list -H $FS 2>/dev/null" | cut  -f 1`
if test "$RFS"; then
  if [ "$FS" = "space/swap" ]; then
    echo skipping $FS
  else
    echo do zfs send -i $...@$p $...@$t I ssh backup zfs recv -vF $RFS
            zfs send -i $...@$p $...@$t | ssh backup zfs recv -vF $RFS
  fi
else
  echo do zfs send $...@$t I ssh backup zfs recv -v $FS
          zfs send $...@$t | ssh backup zfs recv -v $FS
fi
done

ssh backup "zfs destroy -r sp...@$p"
zfs destroy -r sp...@$p



_______________________________________________
zfs-discuss mailing list
zfs-discuss@opensolaris.org
http://mail.opensolaris.org/mailman/listinfo/zfs-discuss

Reply via email to