chiark
/
gitweb
/
~ian
/
chiark-utils.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
fixes from testing on chiark
[chiark-utils.git]
/
backup
/
snaprsync
diff --git
a/backup/snaprsync
b/backup/snaprsync
index c9e77fd2961ceb2ecad8d3ad747d84fcdef27920..3238f392c624af47c90ac11e315691264351a6e0 100755
(executable)
--- a/
backup/snaprsync
+++ b/
backup/snaprsync
@@
-17,6
+17,8
@@
set -e
badusage () { echo >&2 "snaprsync: bad usage: $1"; exit 12; }
x () { echo "+ $@"; "$@"; }
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
while true; do
case "$1" in
@@
-48,15
+50,17
@@
done
datefmt='%Y-%m-%d %H:%M:%S Z'
rsync="rsync ${bwlimit:+--bwlimit} $bwlimit"
export RSYNC_RSH='ssh -o compression=no'
datefmt='%Y-%m-%d %H:%M:%S Z'
rsync="rsync ${bwlimit:+--bwlimit} $bwlimit"
export RSYNC_RSH='ssh -o compression=no'
+sshpfx='PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin; export PATH; '
-ssh $rhost "date -u '+$rhost $datefmt start'"
-ssh $rhost
id
-ssh $rhost
ls -d $rsharedir
-ssh $rhost
ls -d $rvardir
+ssh $rhost "
$sshpfx
date -u '+$rhost $datefmt start'"
+ssh $rhost
"$sshpfx id"
+ssh $rhost
"$sshpfx ls -d $rsharedir"
+ssh $rhost
"$sshpfx ls -d $rvardir"
test -d $localarea || x mkdir $localarea
ournode=`uname -n`
rsumsfile=for-$ournode.sums
test -d $localarea || x mkdir $localarea
ournode=`uname -n`
rsumsfile=for-$ournode.sums
+summer='summer -ACDbtqf'
td=/dev/enoent
rc=12
td=/dev/enoent
rc=12
@@
-66,9
+70,10
@@
td=`mktemp -td`
mkfifo -m 600 $td/sentinel
exec 4<>$td/sentinel
mkfifo -m 600 $td/sentinel
exec 4<>$td/sentinel
-x ssh $rhost "$rsharedir/snap-drop"
-x ssh $rhost "$retcdir/snap/$snapkind snap $rvardir $device $mountpoint"
+x ssh $rhost "$
sshpfx $
rsharedir/snap-drop"
+x ssh $rhost "$
sshpfx $
retcdir/snap/$snapkind snap $rvardir $device $mountpoint"
ssh $rhost <$td/sentinel 4<&- "
ssh $rhost <$td/sentinel 4<&- "
+ $sshpfx
set -e
date -u '+$rhost $datefmt main'
exec 3<&0 0</dev/null
set -e
date -u '+$rhost $datefmt main'
exec 3<&0 0</dev/null
@@
-77,17
+82,26
@@
ssh $rhost <$td/sentinel 4<&- "
umask 077
exec 3>$rsumsfile
cd snap-mount
umask 077
exec 3>$rsumsfile
cd snap-mount
- summer -Ctqf . | sort -t' ' -k2 >&3
- test x"${PIPESTATUS[*]}" = 'x0 0'
+ $summer . >&3
date -u '+$rhost $datefmt sumsdone'
cd ..
" &
date -u '+$rhost $datefmt sumsdone'
cd ..
" &
-rsumpid=$!
+xspawned rsum
x $rsync -aHSxz --numeric-ids --delete \
${localprevious:+--link-dest} $localprevious \
$rhost:$rvardir/snap-mount/. $localarea/.
x $rsync -aHSxz --numeric-ids --delete \
${localprevious:+--link-dest} $localprevious \
$rhost:$rvardir/snap-mount/. $localarea/.
-wait $rsumpid
-x ssh $rhost "$rsharedir/snap-drop"
+date -u "+ $datefmt rsyncdone"
+
+exec 3>$localarea,lsums
+(cd $localarea && \
+ $summer .) &
+xspawned lsum
+exec 3>&-
+
+xwait rsum
+exec 4<&-
+date -u "+ $datefmt sumsdone"
+x ssh $rhost "$sshpfx $rsharedir/snap-drop"
if [ "x${localprevious}" != x ]; then
cp "$localprevious,rsums" "$localarea,rsums"
if [ "x${localprevious}" != x ]; then
cp "$localprevious,rsums" "$localarea,rsums"
@@
-95,3
+109,15
@@
fi
x $rsync -p \
$rhost:$rvardir/$rsumsfile \
"$localarea,rsums"
x $rsync -p \
$rhost:$rvardir/$rsumsfile \
"$localarea,rsums"
+
+xwait $lsum
+date -u "+ $datefmt checking"
+
+set +e
+diff -u "$localarea,rsums" "$localarea,lsums" >"$localarea,sumsdiff"
+diffrc=$?
+set -e
+test $diffrc = 0 || test $diffrc = 1
+
+date -u "+ $datefmt checked $diffrc"
+rc=$diffrc