Does rsync require both source host and destination host to run rsync as client, server, or daemon

rsync

From manpage of rsync

SYNOPSIS

Local:  rsync [OPTION...] SRC... [DEST]
Access via remote shell:
  Pull: rsync [OPTION...] [USER@]HOST:SRC... [DEST]
  Push: rsync [OPTION...] SRC... [USER@]HOST:DEST
Access via rsync daemon:
  Pull: rsync [OPTION...] [USER@]HOST::SRC... [DEST]
        rsync [OPTION...] rsync://[USER@]HOST[:PORT]/SRC... [DEST]
  Push: rsync [OPTION...] SRC... [USER@]HOST::DEST
        rsync [OPTION...] SRC... rsync://[USER@]HOST[:PORT]/DEST

Usages with just one SRC arg and no DEST arg will list the source
files instead of copying

GENERAL

Rsync refers to the local side as the "client" and the remote side as
the "server". Don't confuse "server" with an rsync daemon — a daemon
is always a server, but a server can be either a daemon or a
remote-shell spawned process.

SETUP

See the file README for installation instructions.

Once installed, you can use rsync to any machine that you can access
via a remote shell (as well as some that you can access using the
rsync daemon-mode protocol). For remote transfers, a modern rsync uses
ssh for its communications, but it may have been configured to use a
different remote shell by default, such as rsh or remsh.

You can also specify any remote shell you like, either by using the -e
command line option, or by setting the RSYNC_RSH environment variable.

Note that rsync must be installed on both the source and destination machines.

From synopsis, rsync can be used for

  1. file transferring between local and remote or between local and local.

    When transferring files between local and remote,

    • access via remote shell

    • access via rsync daemon

  2. listing the source files

My questions are

  1. When transferring files between local and remote by accessing via rsync daemon, is the remote host required to run rsync as a daemon?

  2. When transferring files between local and remote by accessing via a remote shell, does the remote host need to run rsync? If yes, does the remote host run rsync as a server but not as a daemon, or just as the local host runs rsync as a client?

  3. When transferring files within the local host, does the local host need to run a rsync client and a rsync server?

  4. When listing the source files instead of copying, if the source is in a remote host, does the remote host need to run rsync as a server or daemon?

  5. Which use cases does "Note that rsync must be installed on both the source and destination machines" apply to, and not apply to, respectively?

  6. In the GENERAL part,
    "a server can be either a daemon or a remote-shell spawned process". Does a remote host running rsync as a server as "a remote-shell spawned process" mean that the remote host runs rsync in the same way as the local host runs rsync?

Note that source and destination hosts can be either local or remote hosts.

Best Answer

When it comes to rsync, think of client and server as roles, that the same rsync binary can fulfill. When it's running as a daemon, you build an rsyncd.conf file, and run rsync with the --daemon argument.

One rsync binary can connect to another (remote) rsync binary either directly - if rsync is running as a daemon listening for it's own connections on a remote host, or via remote shell execution - where rsync uses ssh to connect to a remote host and execute the rsync binary at that host, with both rsync processes passing data back and forth to each other.

To hopefully answer your questions:

  1. When transferring files between local and remote by accessing via rsync daemon, is the remote host required to run rsync as a daemon?

    • Yes. If you're going to access an rsync daemon, that daemon has to be running.
  2. When transferring files between local and remote by accessing via a remote shell, does the remote host need to run rsync? If yes, does the remote host run rsync as a server but not as a daemon, or just as the local host runs rsync as a client?

    • Yes. When rsync has to be available on both hosts, either in the default $PATH, or with the full path to the binary specified in the command options.
  3. When transferring files within the local host, does the local host need to run a rsync client and a rsync server?

    • No. The rsync client binary can function as both roles at the same time if both the SRC and DEST paths are locally available.
  4. When listing the source files instead of copying, if the source is in a remote host, does the remote host need to run rsync as a server or daemon?

    • No, running an rsync daemon is not necessary, a remote client can be triggered if you use rsync -e ssh to access rsync (the client) on the remote host. (The remote-shell-spawned rsync in Q 6.)
  5. Which use cases does "Note that rsync must be installed on both the source and destination machines" apply to, and not apply to, respectively?

    • The rsync binary must be installed on both machines. In the case that the SRC and DEST are the same machine, the lone rsync binary will essentially perform both roles.
  6. In the GENERAL part, "a server can be either a daemon or a remote-shell spawned process". Does a remote host running rsync as a server as "a remote-shell spawned process" mean that the remote host runs rsync in the same way as the local host runs rsync?

    • Yes. Effectively so. The only item of note is that the remotely spawned rsync session is fulfilling the server role.
Related Question