rsync -e 'ssh -p 2222' /home/user/data/ user@backup.example.com:/backup/data/

Category: Backup & Restore

rsync -e 'ssh -p 2222' /home/user/data/ user@backup.example.com:/backup/data/

Sync to a remote host on SSH port 2222

-e passes the whole ssh command, here adding -p 2222 for a non-default port, the standard way to reach SSH on another port. Everything else behaves like a normal remote rsync. Related: rsync -avz -e ssh for the default port.
Looking for more? Search all 7,657 commands — works offline, in English or Spanish, and fixes typos.