> From: Richard Elling [mailto:richard.ell...@gmail.com]
> Question #2:  What's the best way to find the latest matching snap on both
> the source and destination?  At present, it seems, I'll have to build a list 
> of
> sender snaps, and a list of receiver snaps, and parse and search them, till I
> find the latest one that exists in both.  For shell scripting, this is very 
> non-
> trivial.
> Actually, it is quite easy. You will notice that "zfs list -t snapshot" shows 
> the
> list in
> creation time order. 

Actually, I already knew that.  But at the time of initial send, the latest 
snap is most likely a "frequent," which will most likely not exist at a later 
time to be the base of the incremental.  Which means, during the incremental, 
an arbitrary number of the latest snaps on both the sender and receiver 
probably need to be ignored.  In other words, I can't just use a fixed tail or 
awk command...  And I can't alphabetic sort...  

In shell programming land (unless I want to python or something) I'll have to 
nest a for-loop in a for-loop.

export latestmatch=""
export sendersnaps=`ssh otherhost "zfs list -t snapshot | grep $FILESYSTEM" | 
sed 's/ .*//'"`
export receiversnaps=`zfs list -t snapshot | grep $FILESYSTEM | sed 's/ .*//'`
for sendersnap in $sendersnaps ; do
  for receiversnap in $receiversnaps ; do
    if [ "$sendersnap" = "$receiversnap" ] ; then
      export latestmatch = $sendersnap

if [ -z "$latestmatch" ] ; then
  echo "No matching snaps, can't send incremental."
  # Do a full send, or abort
  echo "Doing incremental"
  ssh otherhost "zfs send -I $latestmatch
  ... etc etc...

zfs-discuss mailing list

Reply via email to