I use this rsync invocation to backup my home directory:
rsync -aARrx --info= --force --delete --info=progress2 -F "$USER_HOME" "$BACKUP_MNTPOINT"
rsync man page says that -a implies -g and -o (among other switches), which should preserve ownership. However I've noticed that if a directory does not exist under
$BACKUP_MNTPOINT/$USER_HOME, it is created with root:root ownership instead of the correct one. (This only happens with directories right under
$BACKUP_MNTPOINT/$USER_HOME). Why is that?
$BACKUP_MNTPOINT is a localy mounted drive.
$BACKUP_MNTPOINT/$USER_HOME does have the right ownership and permissions. Neither
$BACKUP_MNTPOINT end with a slash.
Both the source and the target filesystems are XFS and running
mkdir $BACKUP_MNTPOINT/$USER_HOME creates a directory with the expected ownership.