I often use rsync for doing backups. But if you want to do a remote backup and want to backup files and directories which are owned by different users or the root user running using rsync is difficult if you have disabled root login in your sshd_config using the statement PermitRootLogin no. For sure this is the recommended setting if your server to backup has a public IP address.
A nice and easy solution which works best for me is to use sudo. This will allow to run rsync via ssh and sudo. To get it running you have to add an entry into your sudoers config file:
/etc/sudoers
backup_user ALL=(root)NOPASSWD:/usr/bin/rsync
This will allow the user backup_user to run the command rsync as root.
Next step is to add an rsync-path parameter to the remote rsync call:
rsync --rsync-path="sudo rsync"
[email protected]:/root /backup_directory
Finally rsync will automatically do an sudo to root on the remote server and all to backup all files owned by root as well.