From 307c42c2cd5bfa800902805ce99c5558f1afcfd0 Mon Sep 17 00:00:00 2001 From: ianmdlvl Date: Fri, 9 Jun 2006 23:32:46 +0000 Subject: [PATCH] seems to work with test case: PATH=~ian/things/chiark-utils/cprogs:$PATH ./snaprsync --bwlimit=50 davenant /dev/vg_davenant/lv_u /u /bigscratch/private/destination --- backup/snaprsync | 34 ++++++++++++++++++++++++++++++---- 1 file changed, 30 insertions(+), 4 deletions(-) diff --git a/backup/snaprsync b/backup/snaprsync index c9e77fd..67716bb 100755 --- a/backup/snaprsync +++ b/backup/snaprsync @@ -17,6 +17,8 @@ set -e badusage () { echo >&2 "snaprsync: bad usage: $1"; exit 12; } x () { echo "+ $@"; "$@"; } +xspawned () { eval "${1}pid=$!; echo \"+[$!] ($1) &\";"; } +xwait () { eval "echo \"+[\$${1}pid] ($1)...\"; wait \$${1}pid;"; } while true; do case "$1" in @@ -57,6 +59,7 @@ ssh $rhost ls -d $rvardir test -d $localarea || x mkdir $localarea ournode=`uname -n` rsumsfile=for-$ournode.sums +summer='summer -ACDbtqf' td=/dev/enoent rc=12 @@ -77,16 +80,27 @@ ssh $rhost <$td/sentinel 4<&- " umask 077 exec 3>$rsumsfile cd snap-mount - summer -Ctqf . | sort -t' ' -k2 >&3 - test x"${PIPESTATUS[*]}" = 'x0 0' + $summer . | sort -t' ' -k2 >&3 + test x\"\${PIPESTATUS[*]}\" = 'x0 0' date -u '+$rhost $datefmt sumsdone' cd .. " & -rsumpid=$! +xspawned rsum x $rsync -aHSxz --numeric-ids --delete \ ${localprevious:+--link-dest} $localprevious \ $rhost:$rvardir/snap-mount/. $localarea/. -wait $rsumpid +date -u "+ $datefmt rsyncdone" + +exec 3>$localarea,lsums +(cd $localarea && \ + $summer . | sort -t' ' -k2 >&3 && \ + test x"${PIPESTATUS[*]}" = 'x0 0') & +xspawned lsum +exec 3>&- + +xwait rsum +exec 4<&- +date -u "+ $datefmt sumsdone" x ssh $rhost "$rsharedir/snap-drop" if [ "x${localprevious}" != x ]; then @@ -95,3 +109,15 @@ fi x $rsync -p \ $rhost:$rvardir/$rsumsfile \ "$localarea,rsums" + +xwait $lsum +date -u "+ $datefmt checking" + +set +e +x diff -u "$localarea,rsums" "$localarea,lsums" >"$localarea,sumsdiff" +diffrc=$? +set -e +test $diffrc = 0 || test $diffrc = 1 + +date -u "+ $datefmt checked $diffrc" +rc=$diffrc -- 2.30.2