User:Chdev/tarpipe

A tarpipe is the process of creating a tar archive in stdout and then, in another directory, extracting the tar file from the piped stdin. This is a useful way to copy directories and subdirectories, especially if the directories contain special files, such as symlinks, and character or block devices.

tar -cf - "${srcdir}" | tar -C ${destdir} -xf -

Remote tarpipe
A remote tarpipe or ssh tarpipe uses the same methodology of a tarpipe, but instead of simply changing to a new directory on the local host to extract the tar, the user logs into a remote host in order to execute the tar extraction.

tar -cf - "${srcdir}" | ssh ${user}@${remotehost} "tar -C ${destdir} -xf -"

To reverse the process, download instead of upload, the user logs into a remote host in order to create the archive, the tar extraction takes place on the local host.

ssh ${user}@${remotehost} "tar -cf - ${srcdir}" | tar -C ${destdir} -xf -