Sunday, March 13, 2011

SCP: I've been doing it wrong all along

It's not something I have to do a lot, so it's never occurred to me that it might be a problem. If you're transferring a lot of small files with SCP, you're doing it wrong too.

Here, I'm copying an old source code repository to my laptop from my desktop using SCP:

jrodriguez@laptop:~/foo$ time scp -Cqr desktop:/tank/Secure/vcs scp

real 1m49.188s
user 0m0.328s
sys 0m0.392s


Here I'm running the directory through tar and piping it's output through SSH, and back through tar on my side:

jrodriguez@laptop:~/foo$ time ssh desktop tar zcC /tank/Secure/vcs . | tar zxC tar

real 0m7.185s
user 0m0.200s
sys 0m0.144s


That's 789 files totaling 6.6 MB.

Lesson: If you're transferring a lot of small files, don't let SCP do it for you.

No comments: