I needed to keep some content in my laptop synchronized to a NAS. Rsync is the tool of choice, but a simple Rsync command that I was using was not working:

john@mymac.example.com:~/Downloads$ rsync -avz -e ssh source/ user@nas.example.com:/data/stuff/ 
ssh: connect to host nas.example.com port 22: Connection refused
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: unexplained error (code 255) at /SourceCache/rsync/rsync-42/rsync/io.c(452) [sender=2.6.9]

In the above case, the NAS’ ssh deamon was not listening on the default SSH port 22, it was listening on 10022.
So I modified my rsync command accordingly and tried it again:

john@mymac.local:~/Downloads$ rsync -avz -e "ssh -p 10022" source/ user@nas.example.com:/data/stuff/ 
user@nas.example.com's password:
sh: rsync: command not found
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: remote command not found (code 127) at /SourceCache/rsync/rsync-42/rsync/io.c(452) [sender=2.6.9]

This time the rsync program was not found on the NAS, but I knew I had installed the RSYNC module on the NAS. What happened is that the rsync program was not on the path, so it could not be found, but rsync allows you to specify the location of the rsync binary.

john@mymac.local:~/Downloads$ rsync -avz --rsync-path="/raid/data/module/RSYNC/system/bin/rsync" -e "ssh -p 10022" source/ user@nas.example.com:/data/stuff/
user@nas.example.com's password:
building file list ... done

sent 746 bytes  received 20 bytes  306.40 bytes/sec
total size is 8594845389  speedup is 11220424.79

Now I can successfully rsync to the NAS, even though the SSH port and the Rsync binary path are different than the defaults.