Preserve ownership with rsync, without root
As stated in the other answers, to directly preserve ownership information you need root access to the destination machine.
However, you had at least two workarounds to avoid root access while preserving ownership:
- use the
--fake-super
rsync option. From the man page:
When this option is enabled, rsync simulates super-user activities by saving/restoring the privileged attributes via special extended attributes that are attached to each file (as needed)
This means that ownership is not directly preserved in classical Unix style, rather ownership information is stored inside a special extended attribute (ie: a sort of "tag" attached to the file). When restoring, rsync
can use this EA/tag to correctly reconstruct the original file owner.
- do not let rsync preserve ownership information, rather preserve them using the
getfacl
utility. For example, issuinggetfacl -R MNTPOINT > acls.txt
you effectively save ownership (and ACL) info in a text file which can be later used to restore such information using thesetfacl --restore
command.
If I were you, I would put the backups on a volume in a Docker container. This way, you can put good limits on it and avoid security risks but still run it as root so it does what it needs to do.