Jon Simpson

More file & directory copying

8 Mar 2005 — scp, rsync, windows, macosx

Further to my last post about spaced paths and SCP, I ran into SCP not particularly liking the laggy and low-bandwidth nature of the connection I was using it over. This caused some problems with it stalling in the middle of transferring files. As scp seems to overwrite files it has already started retrieving, and this issue seemed to be cropping up quite a lot, I decided to look for a better way.

That better way is rsync, and its been working fine for the last 18 hours or so in retrieving a remote directory structure via ssh. I’m using a command like:

rsync -ave ssh --progress --stats 'user@host:/spaced directory/' /local/path/spaced directory/

Where I already had the path in /spaced directory/ existing. If the directory doesn’t already exist, a command like the following would probably have worked better.

rsync -ave ssh --progress --stats 'user@host:/path/spaced directory' /local/path/

Where /path/ is where the folder the target directory structure is meant to end up under. I’m using the progress and stats flags because of the nature of the link, and its handy to be able to see at a glance how far the transfer is through a particular file.

Getting this method working between my systems was a reasonably simple job. At first I assumed since the destination (iBook) had rsync, I might not need it on the other end, but that turned out to be wrong (rsync didn’t give a very helpful error about it though…) I grabbed rsync for the Windows system on the other end through Cygwin and everything worked a treat.

These last two posts will probably have seemed rather basic to anyone with decent Linux knowledge, but I keep finding more ways the Unix underpinnings of OS X can help me out like this, and it really adds value to the platform. Also since I seem to use these commands infrequently, these kinds of notes on syntax usually end up in tiny text files buried in my home directory. Letting them out onto the web, where I can find them again from other systems is more useful in my opinion, than having them hidden away somewhere.