rsync -a --update resets status of newer target directories
ms at citd.de
Wed Jan 15 17:31:38 MST 2014
On 15.01.2014 22:14, Arvid Requate wrote:
> On 15.01.2014 18:18:13, Matthias Schniedermeyer wrote:
> > As rsync is a tool for unidirectional(!) synchronization of differences
> > between file-trees. I would think: Yes. That is intended behaviour.
> > I don't seen an option to only exclude directories if newer, but there
> > is an option to ignore directory-times completely: --omit-dir-times
> just to avoid a misunderstanding: I was referring to the status of directories
> (mtime, ownership, etc.), not to the files contained below them.
> My intention is to let rsync treat the status of directories just like it
> treats the status of plain files:
> If the option "--update" is specified, it should IMHO only modify the status of
> a target directory if its modification time is not newer than that of the
> source directory.
> It may be a question of debate how to behave if the directory content changed,
> but if it did not change, and the target is newer, then I would expect "--
> update" to protect the target from regressive status changes. This is how it
> works for files. Is there any technical reason why it this option apparently
> has not effect in the case of directories?
- I don't see what your problem is
- The important point is that rsync works unidirectional.
Source is "important", target is either "in sync" or not.
If not it's get the necessary changes, somewhat influenced by options.
- Directory times can only be ignored or explicitly set. At least in the
case when there are changes to files inside the directory rsync would
have to explicitly save and restore a "newer" (relative to source) mtime
on the directory as the mtime gets changed implicitly (by the kernel) at
least for everything that changes the directory contents, e.g. a file
That said, storing and restoring of the mtime of the target is counter
to the unidirectional workings of rsync.
Changes to ctime are similar, they are implicitly set by the kernel when
the inode is changed. The ctime can't even be explicitly (re)set.
- rsync doesn't determine if atime/mtime is bigger/smaller, it only
determines if they are identical or not.
The best rsync can do, is ignore directory-mtimes completely, as in "you
get the mtime of the point in time the directory was last changed"
(Possibly by the last run of rsync)
As far as i can tell something similar goes for "owner", either rsyncs
syncs the owners for everything or for nothing (In the sense of:
Permissions are a little more complicated, especially if you also count
ACLs/xattrs as permissions in a wider sense. But it also boils down to:
Either you sync completely or not at all.
But i can only repeat myself. Rsync works unidirectional. You either
copy something or not. Preserving a newer mtime on target would have to
be activly done by rsync (assuming there are changes to the contents of
said directory , so the act of synchronising the contents of the
directory would trigger an implict mtime), which doesn't fall under
"that is unidirectional" and so is out of scope as far as i can tell or
is my understanding of rsync.
More information about the rsync