Take the 2-minute tour ×

I am retrieving a large files using SCP (from a linux system to a Windows system), now is there any way of compressing that destination file on the fly, for example:

pscp -C root@ Backups\backupdestination.bin

So "backupdestination.bin" would be compressed on the destination drive on the fly.

e.g. C:\backups\backupdestination.zip rather than C:\backups\backupdestination.bin

share|improve this question
add comment

2 Answers

Don't use scp, use ssh :)

The target machine can then "catch" the data. For your example:

ssh root@ "cat /backups/backup1.bin"|gzip -9 -|Backups\backupdestination.bin

This whole scheme will work with anything that can take a contiguous stream of data from stdin and then process it. I'm not aware - off-hand - of a tool that creates ZIP files this way, though. In particular because ZIP files contain the meta-data such as file name and timestamp.

share|improve this answer
Hello, The only issue is that the command is being run from a windows machine :( –  James Teare May 10 '12 at 13:03
Which command? The inner cat or the out ssh? I think PuTTY should be able to deal with it. And even if it's not you can still use Cygwin or MinGW to achieve the goal. Basically, keep in mind that on the (source) machine (in your case) SFTP is only a subsystem to SSH. So if you'd provide a convenient subsystem on that machine to compress already before the data is sent, this could work around the limitations as well. –  0xC0000022L May 10 '12 at 13:05
@afrazier: pscp is from PuTTY, so he's using it already. –  0xC0000022L May 10 '12 at 13:06
Yeah, it took me a re-read to catch that. 7-Zip can handle stdin/stdout redirection if it needs to be done from the Windows system too, and can handle gzip/bzip2, if he doesn't want to use lzma. –  afrazier May 10 '12 at 13:08
add comment

I would suggest rsync, since it has a built in compression flag.

From the rsync man page (http://linux.die.net/man/1/rsync):

-z, --compress              compress file data during the transfer
 --compress-level=NUM    explicitly set compression level
share|improve this answer
add comment

Your Answer


