Copy multiple files via ssh and preserve permissions and ownership 1

Copy multiple files via ssh and preserve permissions and ownership

Copy multiple files via ssh and preserve permissions and ownership.

Creating a tarball on the fly and pipe its output through ssh afterwards extracting the files from the tarball will let us speedup the uploading times because the stream of data is continuous through the network and therefore will be done in one single connection.

File transfers via network will always perform better when we transfer one large file instead of multiple smaller files. We utilize the full bandwidth of our network and disk’s I/O in one TCP connection.

This method is CPU hungry both on source and destination because we are compressing and decompressing data on both machines.

The tarball will preserve all file permissions and ownership.

I used this method when migrating email messages between old and new mail servers. In that case, I had tens of thousands of tiny .eml files and a directory structure that had to be preserved intact.

Rsync or SCP where found slower at my tests, plus, they don’t preserve the permissions and ownership.

I didn’t like the fact that I had no clue about the transfer progress, but, it saved me from the pain of ownership & permissions setting in overall migration process.

If you have a case were multiple larger files (>512KB) should be transferred use Rsync or SCP instead.

Comment:

This site uses Akismet to reduce spam. Learn how your comment data is processed.