On Thu, 20 Jan 2005 17:41:57 +0000, "Martijn Koster" mak-alug@greenhills.co.uk said:
Richard Lewis wrote:
I suppose what I need is a sort of 'rmkdir' with the -p switch:
rmkdir -p $HOST:$ROOT/`dirname $f`
If you can scp to that machine, I presume you can ssh to it too, right? Then you can use ssh to do the mkdir:
Good idea.
I've split the operation in two, first it generates the remote directory tree then it copies all the files: for f in `sort FILES` do d=`dirname $f` if [[ $last != $d ]] then ssh $MIRROR_USER@$MIRROR_IP "[ -d $MIRROR_PATH$d ] || mkdir -p $MIRROR_PATH$d" echo $MIRROR_PATH$d fi last=$d done # copy files....
PS. Theres no need to use scp if a solution exists using something else....
rsync will also do what you want, without the mkdir:
mak@yoda$ ssh taurus mkdir some_dir
mak@yoda$ rsync -e `which ssh` --relative \ /home/mak/foo/bar/baz taurus:some_dir mak@yoda$ ssh taurus ls some_dir/home/mak/foo/bar/baz some_dir/home/mak/foo/bar/baz
What I've got now is /very/ slow.
I had a quick look at the rsync man page and it seems that it makes intelligent descisions about what to copy. I might have to try that.
Thanks for the suggestions.
Cheers, Richard