Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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\ rather than C:\backups\backupdestination.bin

share|improve this question

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

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

From the rsync man page (

-z, --compress              compress file data during the transfer
 --compress-level=NUM    explicitly set compression level
share|improve this answer
OP wants to compress the destination file, not the transfer – golimar Jan 19 '15 at 17:12

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .