Rsync is a free software computer program for Unix and Linux like systems which synchronizes files and directories from one location to another while minimizing data transfer using delta encoding when appropriate.
** Always use rsync over ssh because rsync does not provide any security while transferring data.
rsync over ssh (with password)
rsync -avz ssh /home/user/ firstname.lastname@example.org:/backup/user/
To use a different ssh port, e.g., 123:
rsync -avz 'ssh -p 123' /home/user/ email@example.com:/backup/user/
The terminal will prompt for password before proceed.
To rsync without prompting for password, we can generate a ssh public key and add it to backup server’s ssh authorized keys. Below are the steps.