From 61b5570fa9798f5cef842bb9532286224e6e610a Mon Sep 17 00:00:00 2001 From: Alexander Bassilov Date: Mon, 19 Oct 2020 21:54:04 +0300 Subject: [PATCH 1/2] Update zrep_sync --- zrep_sync | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/zrep_sync b/zrep_sync index a3c311b..79c2451 100644 --- a/zrep_sync +++ b/zrep_sync @@ -320,6 +320,13 @@ _sync(){ "$desthost:zfs recv $recv_s $force $destfs" else if [[ "$token" != "" ]] ; then + # BASSILOV 2020-10-18 when resuming broken sending the last succesful snap will be different than the defined previously + # so we must find the correct one to set zrep:sent property on success. getlastsnapsent should also be fixed to find sync snaps not matching zrep_###### mask + # TO DO this option will not work correctly when used with ZREP_R=-R because it resumes only part of recursive send + # on my system I made additional property zrep:canresume and a script which analizes it and launch zrep with -s parameter when set + newsnap=`zfs send ${ZREP_RESUME_FLAGS} -n -v -t $token | grep 'toname = ' | awk 'BEGIN{ FS=" = "; }{ print $2; }'` + snapname=${newsnap#*@} + eval zfs send ${ZREP_RESUME_FLAGS} -t $token ${Z_F_OUT} | zrep_ssh $desthost "${Z_F_IN} zfs recv $recv_s $force $destfs" else From 95ff08cc9b42dce4ec17851b47ef3d7e15e1df99 Mon Sep 17 00:00:00 2001 From: Alexander Bassilov Date: Mon, 19 Oct 2020 22:00:24 +0300 Subject: [PATCH 2/2] Update zrep_snap --- zrep_snap | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/zrep_snap b/zrep_snap index f48d42b..a23c267 100644 --- a/zrep_snap +++ b/zrep_snap @@ -52,8 +52,10 @@ getlastsnapsent(){ # arg. more efficient if we can just return value directly, # but i'm using backwards compat :( typeset lastsent - lastsent=`zfs get -H -o name -r -s local ${ZREPTAG}:sent $1 | - sort | tail -1` + # BASSILOV 2020-10-18 sorting by name is not good way because the last sent snap can be not from zrep (when resuming sendings for example) + ## lastsent=`zfs get -H -o name -r -s local ${ZREPTAG}:sent $1 | + ## sort | tail -1` + lastsent=`zfs get -H -o value,name -r -s local ${ZREPTAG}:sent $1 | sort -n | tail -1 | awk '{print $2;}'` if [[ "$lastsent" != "" ]] ; then print $lastsent return