#!/bin/sh # Given (local) "source" and (remote) "destination" directories, # generate an "intermediate" directory containing all the files from the # source that need updating in the destination. This lets you # synchronise two directory trees on machines connected by a slow link # by carrying a hard disk around. # Adam Sampson usage () { echo "Usage: sneakersync [-e SSH] [-n] SOURCE DESTINATION INTERMEDIATE" echo "e.g. sneakersync -e 'ssh -A gatehost ssh' music host:/u1/music /disk/music" } eopt="-essh" nopt="" while getopts "e:n" c; do case $c in e) eopt="-e$OPTARG" ;; n) nopt="-n" ;; \?) usage exit 0 ;; esac done shift `expr $OPTIND - 1` source="$1" dest="$2" inter="$3" if [ "$3" = "" ]; then usage exit 1 fi tempfile="/tmp/sneakersync$$" trap "rm -f $tempfile" 0 rsync "$eopt" -nav $source/ $dest \ | egrep -v '(^building file list|^$|^sent [0-9]|^total size is|/$)' \ >$tempfile rsync $nopt -av --partial --files-from $tempfile $source/ $inter