I frequently transfer large directories over scp
and it would be sweet if I could somehow compress the directory, send it, and decompress it all in one.
Is something like this possible?
How about using rsync
instead with the -z
option enabled for compression?
rsync -az --progress source_dir/* remote_host:/destination_dir
This also has the added benefit that if the file already exists and has not changed on the destination, it will not be transferred.
Thanks to @johnshen64's answer, I was able to come up with something quite nice
tar -zc path/to/source | ssh user@remote tar -zxC path/to/destination
Unfortunately, this doesn't show progress as it transfers. I have noticed incredible speed improvements using this method.
If anyone know how to show progress for a transfer like this, I'd greatly appreciate the help :)
well, i would use tar instead
tar cf - directory | ssh server 'tar xf -'
you can add v to verify.
zip should be the same, but tar is more robust for linux in my opinion.
-
character, also uses gzip compression and allows to target a destination directory.
f -
might be required on other operating systems, since most tar versions will try to read from a tape drive otherwise. Reading from stdin by default is GNU-specific.
May 7, 2012 at 18:39