Using custom port for rsync over ssh

I’m using following command to archive local directory to a remote server with rsync through ssh tunnel:

$ rsync -a /local/dir user@host:/backup/dir

I want to use same functionality with another server but this time, ssh runs on a non-standard port (14022) on the remote side. How can I use rsync over ssh with custom port?

You can use any ssh parameter if you start to tunnel with -e option like that:

$ rsync -a -e "ssh -p 14022" /local/dir user@host:/backup/dir

For example, if you want to force using IPv6 addresses, just add standard -6 ssh parameter to above command:

$ rsync -a -e "ssh -p 14022 -6" /local/dir user@host:/backup/dir

You can combine any other ssh parameters in that way.

See: man ssh