From: ianmdlvl Date: Wed, 7 Jun 2006 00:11:28 +0000 (+0000) Subject: wip X-Git-Tag: debian_version_4_1_0~7 X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ian/git?p=chiark-utils.git;a=commitdiff_plain;h=e1335e736b64e6123950276c44dc8d82fc96b655 wip --- diff --git a/backup/snaprsync b/backup/snaprsync index a2bc96d..c9e77fd 100755 --- a/backup/snaprsync +++ b/backup/snaprsync @@ -11,6 +11,9 @@ rsharedir=/usr/share/chiark-backup retcdir=/etc/chiark-backup rvardir=/var/lib/chiark-backup + bwlimit= + +set -e badusage () { echo >&2 "snaprsync: bad usage: $1"; exit 12; } x () { echo "+ $@"; "$@"; } @@ -22,7 +25,7 @@ while true; do value=${1#--*=} case "$name" in rhost|device|mountpoint|localarea);; - localprevious|rsharedir|retcdir|rvardir);; + localprevious|rsharedir|retcdir|rvardir|bwlimit);; *) badusage "unknown setting $name";; esac eval "$name=\$value" @@ -43,8 +46,10 @@ for name in rhost device mountpoint localarea; do done datefmt='%Y-%m-%d %H:%M:%S Z' +rsync="rsync ${bwlimit:+--bwlimit} $bwlimit" +export RSYNC_RSH='ssh -o compression=no' -ssh $rhost "date -u '+$rhost $datefmt'" +ssh $rhost "date -u '+$rhost $datefmt start'" ssh $rhost id ssh $rhost ls -d $rsharedir ssh $rhost ls -d $rvardir @@ -53,26 +58,40 @@ test -d $localarea || x mkdir $localarea ournode=`uname -n` rsumsfile=for-$ournode.sums +td=/dev/enoent +rc=12 +trap 'rm -rf $td; exit $rc' 0 +td=`mktemp -td` + +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" -ssh $rhost " - set -ex +ssh $rhost <$td/sentinel 4<&- " + set -e + date -u '+$rhost $datefmt main' + exec 3<&0 0$rsumsfile cd snap-mount - summer -Cqf . >&3 - date -u +'sums done $datefmt' + summer -Ctqf . | sort -t' ' -k2 >&3 + test x"${PIPESTATUS[*]}" = 'x0 0' + date -u '+$rhost $datefmt sumsdone' cd .. " & -fixme kill this thing if we die rsumpid=$! -RSYNC_RSH='ssh -o compression=no' \ - x rsync -aHSxz --numeric-ids --delete \ +x $rsync -aHSxz --numeric-ids --delete \ ${localprevious:+--link-dest} $localprevious \ $rhost:$rvardir/snap-mount/. $localarea/. wait $rsumpid x ssh $rhost "$rsharedir/snap-drop" -RSYNC_RSH=ssh rsync -p - fixme use localprevious,rsums as seed if available - $rhost:$rvardir/$rsumsfile $localarea,rsums + +if [ "x${localprevious}" != x ]; then + cp "$localprevious,rsums" "$localarea,rsums" +fi +x $rsync -p \ + $rhost:$rvardir/$rsumsfile \ + "$localarea,rsums"