If you insist on using scp the following may provide a serial means to transfer files, but note it will need to negotiate a key based session before transferring each file, so if the number of files is large the so will the negotiation overhead:
cd /some/local/directory/
find . -type d -exec ssh
[email protected] 'cd /some/remote/directory;mkd
ir -p .{}' \;
find . -type f -exec scp {} localhost:/some/remote/dir
ectory/{} \;
Personally I'd use rsync over ssh e.g.
#!/bin/sh
RSYNC=`which rsync`
SOURCE_DIR='/some/local/di
rectory'
TARGET_DIR="$SOURCE_DIR"
$RSYNC -optl --delete-after --rsh=/usr/bin/ssh --rsync-path=$RSYNC --force $SOURCE_DIR/ ${REMOTE_HOST}:${TARGET_DI
R}
Then again the following tar pipe solution may work for the first couple of GB worth of files:
cd /some/local/directory && tar cf - . | ssh
[email protected] "cd /some/remote/directory; tar xf -"
If the boxes are not secure, no pesky firewalls, then the following netcat (port binding) approach may suit:
http://compsoc.dur.ac.uk/~djw/tarpipe.html Note: Could always add a ssh tunnel if there is a firewall in the way.