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 $USER_HOME
nor $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.
$BACKUP_MNTPOINT
and with what options is it mounted? Does this happen only for the parent ($BACKUP_MNTPOINT/$USER_HOME
) directory or for all directories created? Do$BACKUP_MNTPOINT
and$USER_HOME
end with a/
?/home
and the backup drive. So far I think it only happened for the parent directories. Neither$BACKUP_MNTPOINT
nor$USER_HOME
end with a slash. EDIT: I can confirm now it only happens to the directories right below$BACKUP_MNTPOINT/$USER_HOME
$BACKUP_MNTPOINT/$USER_HOME
has the right permissions but any subdirectories do not? Please edit your question and add these details. Also, clarify whethermkdir $BACKUP_MNTPOINT/$USER_HOME/foo
creates a directory owned by your user if you do it manually.mkdir $BACKUP_MNTPOINT/$USER_HOME/foo
creates a directory with the user's ownership.strace
(as specified in a pseudo answer).