Today I had to copy a bunch of files and symlinks to a remote machine. My first attempt was to use scr directly:
$ scp -r directory host:/some/directory
But that went wrong: the symlinks were not preserved, which resulted in several files being transferred multiple times.
A simple solution could have been to create a tarball of the whole directory, copy it to the remote host and unpack it there. However, I thought... using tar on both ends through a pipe over SSH should work... so I tried... and it worked! So how is this done?
$ cd directory ; tar cvf - . | ssh sun tar xf - -C /some/directory
Yes, it's that easy! Hmm I ask myself why I didn't try this before... BTW, remember that the target directory should exist; if it doesn't, adjust the command line a bit ;-)