I wanted to backup an aws machine and exclude os files, only user files including root owned ones which need sudo permission to read.
rsync -aAXv --rsync-path="sudo rsync" -e ssh \
--exclude={"/swapfile","/var/lib/*","/var/cache/*","/usr/*","/sbin/*","/lib/*","/home/admin/go/*","/home/admin/downloads/*","/home/admin/.sdkman/*","/home/admin/.oh-my-zsh/*","home/admin/.rbenv/*","home/admin/.nvm/*","/home/admin/.npm/*","/home/admin/.m2/*","/home/admin/.gvm/*","/home/admin/.cache/*","/dev/*","/boot/*","/proc/*","/sys/*","/tmp/*","/run/*","/mnt/*","/media/*","/lost+found"} \
admin@ec2-3-122-251-181.eu-central-1.compute.amazonaws.com:/ \
~/aws_machine
-e ssh: specifies that the rsync command should use the ssh protocol for the transfer.
--rsync-path="sudo rsync" fixes the permission denied for non-user owned files and folders