I use rsync in a fairly complex scripted situation and am trying to figure out how to avoid changing ownership/permissions just on the directories specified on the command line (but operate normally for everything underneath). I've been using --relative --no-implied-dirs with some success in other situations, but here it still seems to try to chown the last path component of the implied-dirs, even when the /./ separator is appended. When I use verbose, I see that rsync does a chdir() to the implied dir on the receiving end, but then also tries to chown('.') which I don't expect it to be doing. I expected rsync to not try to change permissions or ownership on everything before the /./ separator. E.g. backing up and restoring my Windows home directory which is owned by SYSTEM:SYSTEM with everything underneath owned by me:me to a remote Linux server with everything owned by me:me: rsync -a --super --relative --no-implied-dirs "--filter=. HomeWin.rfilter" /cygdrive/c/Users/me/./ myserver:/WinBACKUP/Users/me/ where HomeWin.rfilter is anchored at a Windows home directory and contains something like: + /Pictures/ - /* This ends up failing to chown SYSTEM:SYSTEM /WinBACKUP/Users/me (permission denied; no such user/group). I have a usable workaround which is just to chown me:me /cygdrive/c/Users/me, but it would be nice to figure out a proper solution without risking Windows issues. Any help, ideas would be appreciated. Thanks, -- Chris
Francis.Montagnac at inria.fr
2019-Aug-28 06:31 UTC
implied-dirs tail component being chown'd
Hi. On Tue, 27 Aug 2019 14:56:25 -0700 Chris Roehrig via rsync wrote:> rsync -a --super --relative --no-implied-dirs "--filter=. HomeWin.rfilter" /cygdrive/c/Users/me/./ myserver:/WinBACKUP/Users/me/If you are connecting to myserver as you (not root), simply suppressing the --super option should work. Otherwise (with a recent version of rsync) add: --chown me:me -- francis
Thanks Francis, Neither of those really do what I'd like: to properly sync/preserve ownership/attributes for files below the root of the transfer (which are not necessarily me:me -- I use groups for sharing between users), but to leave the root attributes untouched, and to use filters anchored at the root. Upon re-reading the man page, I see I misunderstood how /./ and --no-implied-dirs works. I thought I could use them to solve this problem, but it doesn't look like it. From my perspective it seems like a mis-match between where filters are anchored ("exclude the root") and where attributes are touched ("include the root"). This is a situation I encounter a fair bit. On Windows and Mac there are a lot of user directories that are system-owned or have special system ACLs, xattrs, etc: $HOME, Downloads, Desktop, Library, etc, and I would like rsync to avoid touching those ownership/attributes, but also to use filters that are anchored at the root of those (so that they can be applied globally to any user). E.g. backup: rsync -a ". HomeDir.rfilter" /Users/<someuser>/./ server:BACKUPDIR/Users/<someuser>/ restore: rsync -a ". HomeDir.rfilter" server:BACKUPDIR/Users/<someuser>/./ /Users/<someuser>/ where HomeDir.rfilter is anchored at a user's home directory (and therefore applies to any user) and attributes to the left of the /./ remain untouched (which was my misunderstanding -- it doesn't work that way). I hope this illustrates the issue I'm trying to solve. I had thought this might be a somewhat common problem, but it doesn't seem like there is a good solution to this. The easiest workaround for me so far is just to overwrite the Mac/Windows system-owned attributes and make them owned by <someuser>:<someuser>, but it's not ideal. -- Chris On Tue Aug 27 2019, at 11:31 PM, Francis.Montagnac at inria.fr wrote:> > Hi. > > On Tue, 27 Aug 2019 14:56:25 -0700 Chris Roehrig via rsync wrote: > >> rsync -a --super --relative --no-implied-dirs "--filter=. HomeWin.rfilter" /cygdrive/c/Users/me/./ myserver:/WinBACKUP/Users/me/ > > If you are connecting to myserver as you (not root), simply > suppressing the --super option should work. > > Otherwise (with a recent version of rsync) add: --chown me:me > > -- > francis