Copying with tar

linux Feb 03, 2020

Sometimes when dealing with millions of small files to copy you need to use tar|tar to copy over the network faster. I always have to spend 10 minutes reading man pages or looking up google to find the syntax to do this, when both source and destination paths are mounted on the same host then the following works:

tar cvf - . | (cd /<destination path>/; tar xvf -)

Keeping in mind that the transport will be whatever the mount type is (ie NFS/SMB/local/etc). The benefit of tar is that it will keep pipes and other special files. It will also pack the data over the network better than copying file by file (especially for a lot of very small files).