Rsync is a fast, versatile, remote (and local) file-copying tool.
The rsync command is a very handy and straightforward tool if you want to copy files/folders between your machine and a remote one.
Let’s see some use cases:
Copying local files/folders to a remote computer
Let’s say we have a folder named foo and we want to copy it on the user’s home folder on the remote machine:
rsync -avz foo firstname.lastname@example.org:/home/user/
-a option: archive mode; equals -rlptgoD (no -H,-A,-X)
-v option: verbose output
-z option: compress files
Note that when you execute the command, it will ask for the remote user’s password.
Copying remote files/folders to local storage
Now, let’s say that you want to copy the remote folder named foo to your local storage:
rsync -avz email@example.com:/home/user/foo .
Non-standard SSH port
If the remote server’s sshd port is not the standard one, you can specify the correct one using the -e option.
e.g. for port 12345:
rsync -avz -e "ssh -p12345" firstname.lastname@example.org:/home/user/foo .