rsync remote port

If you are running ssh on a non standard port you can still use rsync over ssh with the following syntax. rsync is a powerful tool to create simple backup and deployment workflows. Here are some examples with common rsync use cases …

Copy files from remote to local

rsync -avz -e "ssh -p REMOTE_PORT" [email protected]_SERVER:/remote/path/ /local/path

The options “-av” are the most common options for rsync (archive mode with verbose output). This includes being recursive, copy links as links, preserve permissions, preserve times and preserve owner/group. The “-z” options means that the content is compressed before the transfer. From my experience I recommend that you always use the “–dry-run” switch first to see what will happen (rsync will not ask you before overwriting files etc.).

Copy files from local to remote, show progress

rsync -avz -e "ssh -p REMOTE_PORT" /local/path [email protected]_SERVER:/remote/path/

Do not copy files – just show what would be copied (test run)

rsync -avz --dry-run -e "ssh -p REMOTE_PORT" /local/path [email protected]_SERVER:/remote/path/

So let’s assume we have REMOTE_PORT = 1234, REMOTE_USER = admin, REMOTE_SERVER = … the first example would be:

rsync -avz -e "ssh -p 1234" [email protected]:/remote/path/ /local/path