Hello, friends. Today we are going with a post dedicated to Linux newbies and not so newbies. Today, we will tell you the best way to copy large folders on Linux.
Although most of the files nowadays are stored in the cloud, it is not surprising that many people have them on their computers or external drives. The reasons for this vary, but one of them may be the security of having them with them at all times or the impossibility of connecting to the internet.
However, the question arises on Linux, how to do it efficiently? Well, although there are commands on Linux that allow you to do so, they are not always effective or efficient. Some because they do not tolerate failures and others because they do not allow to have a screen output that indicates the process.
In addition to this, it must also be said that using the file browser to copy, say, 100Gb is not entirely comfortable. But what if the size is even more? The situation changes.
The best way to copy large folders on Linux
Let’s talk about the cp command
The cp command is a simple to use Linux command that copies the contents of one folder to another.
Using the above definition, it is normal that we think that this command is the best to achieve the objective. However, although it can fulfill it, the truth is that in large operations it has some details.
The first of them is that if during the process something were to fail, the cp command has no way to summarize the process, so we would not know which part of the process would be successful. Another aspect to keep in mind is that you would not be able to know the process as such.
However, it is a command that performs the process very well in low-weight situations.
For these cases, the best is rsync
rsync is an open-source utility that provides fast incremental file transfer. So, although it is not a tool intended to copy files like
cp it is true that it is the basis of many backup tools.
rsync can be used to copy those large folders. What are its advantages? Well, a progress bar, fault tolerance and a great copying speed.
Therefore, it is the recommended option.
Install rsync on Linux
sudo apt install rsync
This is partly because the tool is present in the official repositories of these distributions.
In the case of RHEL, Alma Linux, Rocky Linux and others
sudo dnf install rsync
Of course, it is unlikely that rsync is not present in the official repositories of your distribution.
Copying large folders with rsync
One thing sets rsync apart, and that is the sheer number of options it has. However, in a nutshell, you can run this command
rsync -av --progress /mnt/folder /mnt/folder2
-a: The archive mode behaves like the recursive mode but keeps all file permissions, symbolic links, file ownership, etc.
-v: Just, displays the details of the transfer.
–progress: Displays the transfer progress during synchronization.
So, it’s that easy.