+ ## Copy files from the remote snapshot.
+ maybe mkdir -p new/
+ case $dryrun in
+ t) $verbose " running rsync" ;;
+ nil) $verbose -n " running rsync..." ;;
+ esac
+ set +e
+ run "RSYNC of $host:$fs (snapshot on $snapmnt)" do_rsync \
+ $linkdests \
+ $rsyncargs \
+ $snapmnt/ new/
+ rc_rsync=$?
+ set -e
+ case $dryrun in nil) $verbose " done" ;; esac
+
+ ## Collect a map of the snapshot for verification purposes.
+ set +e
+ case $dryrun in
+ t) $verbose " remote fshash" ;;
+ nil) $verbose -n " remote fshash..." ;;
+ esac
+ run "@$host: fshash $fs" remote_fshash
+ rc_fshash=$?
+ set -e
+ case $dryrun in
+ nil)
+ hrfs=$(hash_file "new.fshash")
+ log "remote fshash $HASH checksum: $hrfs"
+ $verbose " done"
+ ;;
+ t)
+ hrfs=UNSET
+ ;;
+ esac
+
+ ## Remove the snapshot.
+ maybe unsnap_$snap $snapargs $fs $fsarg
+ $verbose " remove snapshot"
+
+ ## If we failed to copy, then give up.
+ case $rc_rsync:$rc_fshash in
+ 0:0) ;;
+ 0:*) return $rc_fshash ;;
+ *) return $rc_rsync ;;
+ esac
+
+ ## Get a matching map of the files received.
+ maybe mkdir -m750 -p $STOREDIR/tmp/
+ localmap=$STOREDIR/tmp/fshash.$host.$fs.$date
+ case $dryrun in
+ t) $verbose " local fshash" ;;
+ nil) $verbose -n " local fshash..." ;;
+ esac
+ run "local fshash $host:$fs" local_fshash || return $?
+ case $dryrun in
+ nil)
+ hlfs=$(hash_file "$localmap")
+ log "local fshash $HASH checksum: $hlfs"
+ $verbose " done"
+ ;;
+ t)
+ hlfs=UNSET
+ ;;
+ esac
+
+ ## Compare the two maps.
+ set +e
+ fshash_diff=$STOREDIR/tmp/fshash-diff.$host.$fs.$date
+ run "compare fshash maps for $host:$fs" \
+ run_diff $fshash_diff new.fshash $localmap
+ rc_diff=$?
+ set -e
+ case $rc_diff in
+ 0)
+ break
+ ;;
+ 1)
+ if [ $attempt -ge $retry ]; then return $rc; fi
+ $verbose " fshash mismatch; retrying"
+ attempt=$(( $attempt + 1 ))
+ ;;
+ *)
+ return $rc_diff
+ ;;
+ esac
+ done
+
+ ## Double-check the checksums.
+ if [ $hrfs != $hlfs ]; then
+ cat >&2 <<EOF
+$0: INTERNAL ERROR: fshash $HASH checksum mismatch -- aborting
+ remote fshash checksum = $hrfs
+ local fshash checksum = $hlfs
+EOF
+ exit 127
+ fi