Synchronize files between servers
to synchronize files between servers two linux servers we will need to use the command rsync
here is an example to synchronize files in folder ( /home/folders ) from ( remoteserver ) to current server on the folder /home/folders/
rsync -avzh -e root@remoteserver:/home/folders/ /home/folders/
to use ssh key, we will need to set the key as keyname.pem with permission 600 or 400 and use the command as following
rsync -avzh -e 'ssh -i ~/keyname.pem' root@remoteserver:/home/folders/ /home/folders/
if we need to use another port than 22 for example port 23 we will use the command as
rsync -avzh -e 'ssh -p 23 -i ~/keyname.pem' root@remoteserver:/home/folders/ /home/folders/