How to specify custom SSH port when using rdiff-backup

Specify a custom SSH port when using rdiff-backup.

rdiff-backup is using standard SSH port when connecting to the remote host.

$ rdiff-backup --print-statistics ~/Projects/personal/ rdiff-backup@backup.example.org::/rdiff-backup/repositories/personal
ssh: connect to host backup.example.org port 22: Connection refused
Fatal Error: Truncated header string (problem probably originated remotely)
Couldn't start up the remote connection by executing
    ssh -C rdiff-backup@backup.example.org rdiff-backup --server
Remember that, under the default settings, rdiff-backup must be
installed in the PATH on the remote system.  See the man page for more
information on this.  This message may also be displayed if the remote
version of rdiff-backup is quite different from the local version (2.0.0).

See the manual page to see how to specify additional connection parameters.

[…]
–remote-schema schema
Specify an alternate method of connecting to a remote computer. This is necessary to get rdiff-backup not to use ssh for remote backups, or if, for instance, rdiff-backup is not in the PATH on the remote side. See the REMOTE OPERATION section for more
information.
[…]
The default remote schema is ‘ssh -C %s rdiff-backup –server’ where host_info is substituted for ‘%s’. So if the host_info is user@host.net, then rdiff-backup runs ‘ssh user@host.net rdiff-backup –server’. Using –remote-schema, rdiff-backup can invoke an
arbitrary command in order to open up a remote pipe. For instance,
rdiff-backup –remote-schema ‘cd /usr; %s’ foo ‘rdiff-backup –server’::bar
is basically equivalent to (but slower than)
rdiff-backup foo /usr/bar
[…]

rdiff-backup manual

The default remote schema is ssh -C %s rdiff-backup --server, so alter it to specify remote port.

$ rdiff-backup --print-statistics --remote-schema "ssh -C -p 2222 %s rdiff-backup --server" ~/Projects/personal/ rdiff-backup@backup.example.org::/rdiff-backup/repositories/personal
--------------[ Session statistics ]--------------
StartTime 1599393121.00 (Sun Sep  6 11:52:01 2020)
EndTime 1599393121.48 (Sun Sep  6 11:52:01 2020)
ElapsedTime 0.48 (0.48 seconds)
SourceFiles 11
SourceFileSize 10543 (10.3 KB)
MirrorFiles 1
MirrorFileSize 0 (0 bytes)
NewFiles 10
NewFileSize 10543 (10.3 KB)
DeletedFiles 0
DeletedFileSize 0 (0 bytes)
ChangedFiles 1
ChangedSourceSize 0 (0 bytes)
ChangedMirrorSize 0 (0 bytes)
IncrementFiles 0
IncrementFileSize 0 (0 bytes)
TotalDestinationSizeChange 10543 (10.3 KB)
Errors 0
--------------------------------------------------

It is as easy as that.