There are several common ways to do rsync backups of hosts over ssh:
- As a non-root user. Upsides: very secure. Downside: cannot back up sensitive files.
- As root, with a public key. Downsides: Whoever has the private key has full root access to the host being backed up.
- As root, with a public key and a "forced command". Upsides: Restricts access to the server. Downsides: Requires either careful matching of rsync options (which might change over time), or "validator" scripts. Neither idea sounds very appealing to me.
- Running rsync in daemon mode on the host being backed up. Upsides: Lots of useful options, like read-only mode, running as a different user if required, server-side excludes/includes, etc. Downsides: Opens up a TCP port that has full filesystem read access and is hard to secure (Ideally you could make the rsync daemon use a unix socket instead, that could be secured by filesystem permissions, but I haven't found a way to do that).
Here is another option t