Quantcast
Viewing latest article 2
Browse Latest Browse All 4

Answer by dkbhadeshiya for scp and compress at the same time, no intermediate save

I think this command will do the trick

ssh user@host "cd /path/to/data/;tar zc directory_name" | tar zx 

EDIT: an earlier version was with two wrong "f" options.

Now, first of all you have to execute this command from the target host. And details to be explained:

  1. ssh user@host will open connection to host machine, from where the data is to be transfered.
  2. cd /path/to/data will take to the directory where required data is stored
  3. tar zc * will initiate compression and put it to the STDOUT
  4. Now pipe(|) will pipeline the STDOUT of the source to the STDIN of the destination where "tar zx " is running and continuously decompression data stream coming from source.

As you can see this command compresses on-the-fly and saves bandwidth. You can use other compressions as well for better results, but remember, compression and decompression needs CPU cycles.

Reference


Viewing latest article 2
Browse Latest Browse All 4

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>