Rsync over SSH

User of rsync command

rsync -Pzarve (P-progress, z-compress, a-archive, r-recursive, v-verbose, e-method) ssh -p (port) -i (ssh key location) /local/dir/ user@hostname:/remote/dir/
if you are using rsa key then do rsync -Pzarve "ssh -i /location/rsa_key -p 1234" /source /destination

#In this way you have to type password every time you do rsync, if you do not want to enter password every time then you have to make passwordless ssh login. To make passwordless ssh login please check my other Post.

To be / or not to be / ——– That is the big question:

#1: rsync -Pzarve /local/dir/path/ /remote/other-dir/
#2: rsync -Pzarve /local/dir/path /remote/other-dir/

Answer:
#1) will make /remote/other-dir mirror the contents of /local/dir/path/,
#2) will create a directory in /remote/other-dir/path/ whose contents will mirror /local/dir/path/.


Be warned! If you’re not careful and you use #1 when you intend to use #2, you can lose files in /remote/other-dir.

Another Method

rsync -Pzarv /local/dir/path/. /remote/other-dir/