rysnc
rsync
is built into most Linux distributions. Here, I will use Pop!_OS 22.04 to show you some rsync
basics.
The basic rsync
command which can solve a lot of scenarios is something like this:
rsync -rv dir1/ dir2
What this means:
-r
switch means to copy everything recursively.-v
means to provide logging of the actions performed. This is also known as “verbose” mode.
Now, when it comes to specifying directories, it is important to know that the format here is in: src dest
. If the src
folder does not have a trailing /
, then that means that specific directory will be created under dest
, followed by the rest of the files underneath it.
Here is an example:
rsync -rv /home/rogerngo/Desktop/test-share/ /home/rogerngo/Desktop/backup
Remote Syncing
Now, here is how you can do it from one PC to another remotely, or the other way around. You can do it pretty easily because rsync
uses SSH underneath the hood.
It is just like scp
in the format of:
rsync -rv src dest
Where is src
is a remote host, it can be something like this:
rsync -rf rogerngo@192.168.1.83:/home/rogerngo/Desktop/test-share/ ~/backup
This will sync from a remote host test-share
files into the local computer’s backup
folder.
The other way around works too – if you want to sync stuff from a local computer to remote host:
rsync -rf ~/test-share rogerngo@192.168.1.83:/home/rogerngo/Desktop/backup