Linux – fastest way to mirror a directory containing millions of small files

copylinuxrsync

I need to copy a 700G ISCSI mounted folder to a folder on the local hard drive, while maintaining the existing permissions and ownership. The data in the folder consists of about a million mostly small files, and the new directory needs to exactly match the permissions and ownership of the original.

Using

rsync -az /original_folder/ /new_folder

gets all the permissions correct, but it has been over an hour "scanning for files", and has not even started coping over yet. The data is openvz disk shares, and there have been permission problems in the past when they were copied over using "cp".

Is there a faster way to copy a huge number of small files while exactly preserving the permissions and ownership? Maybe some rsync flags that can avoid the initial scan? Ideally a tool that can pick up where you left off if the process is interrupted.

Best Answer

Have you considered using tar? Something along the lines of tar -cpOC <sourcedir> . | tar -xpC <targetdir> -f - might do you.