rsync does not sync the timestamp on symlink (Solaris 8). It is probablly due to the limitation of Unix implementation of symlink, but I would like to know why rsync/Unix does not do this, and what we can do about it. Is the conclusion that "rsync syncs everything except the timestamp on symlink"? Why do I need timestamp on symlink? Supposed something stopped working because something removed the link, and then remake the link. If all I have is the rsync copy, then I would have a wrong conclusion, for example, that "nobody touched the directory since last night." Thanks. [root@emily:/tmp]ls -ls a/copying b/copying 8 lrwxrwxrwx 1 root other 7 Jul 28 12:09 a/copying -> COPYING 8 lrwxrwxrwx 1 root other 7 Jul 28 12:07 b/copying -> COPYING [root@emily:/tmp]rsync -avn /tmp/a/ /tmp/b building file list ... done wrote 25424 bytes read 20 bytes 16962.67 bytes/sec total size is 15972287 speedup is 627.74 [root@emily:/tmp]rsync -av /tmp/a/ /tmp/b building file list ... done ./ wrote 25424 bytes read 20 bytes 16962.67 bytes/sec total size is 15972287 speedup is 627.74 [root@emily:/tmp]ls -ls a/copying b/copying 8 lrwxrwxrwx 1 root other 7 Jul 28 12:09 a/copying -> COPYING 8 lrwxrwxrwx 1 root other 7 Jul 28 12:07 b/copying -> COPYING -- Michael Wang http://www.unixlabplus.com/
On 28 Jul 2002, Michael Wang <mwang@mindspring.com> wrote:> rsync does not sync the timestamp on symlink (Solaris 8). > > It is probablly due to the limitation of Unix implementation > of symlink, but I would like to know why rsync/Unix does not > do this, and what we can do about it. Is the conclusion that > "rsync syncs everything except the timestamp on symlink"?I don't think it is possible to set the time of a symbolic link. A quick experiment on Linux seems to confirm that: !891 12:36 ~% python2.2 Python 2.2.1 (#1, May 3 2002, 23:19:03) [GCC 2.95.4 20011002 (Debian prerelease)] on linux2 Type "help", "copyright", "credits" or "license" for more information.>>> import os >>> os.symlink('nothere', '/tmp/mylink') >>> os.utime('/tmp/mylink', None)Traceback (most recent call last): File "<stdin>", line 1, in ? OSError: [Errno 2] No such file or directory: '/tmp/mylink' The Sun manpage doesn't comment on how they think this ought to work, so presumably they're trying to update the link's target too. You will need to do a backup below the filesystem API (e.g. using dump) if you want to preserve them, as far as I can see.> Why do I need timestamp on symlink? Supposed something stopped > working because something removed the link, and then remake > the link. If all I have is the rsync copy, then I would have > a wrong conclusion, for example, that "nobody touched the directory > since last night."You will see that the directory's modification time has changed; you will also see that the new symlink has a later time than that in the backup.> [root@emily:/tmp]ls -ls a/copying b/copying > 8 lrwxrwxrwx 1 root other 7 Jul 28 12:09 a/copying -> COPYING > 8 lrwxrwxrwx 1 root other 7 Jul 28 12:07 b/copying -> COPYING > > [root@emily:/tmp]rsync -avn /tmp/a/ /tmp/b > building file list ... done > wrote 25424 bytes read 20 bytes 16962.67 bytes/sec > total size is 15972287 speedup is 627.74 > > [root@emily:/tmp]rsync -av /tmp/a/ /tmp/b > building file list ... done > ./ > wrote 25424 bytes read 20 bytes 16962.67 bytes/sec > total size is 15972287 speedup is 627.74 > > [root@emily:/tmp]ls -ls a/copying b/copying > 8 lrwxrwxrwx 1 root other 7 Jul 28 12:09 a/copying -> COPYING > 8 lrwxrwxrwx 1 root other 7 Jul 28 12:07 b/copying -> COPYINGWhat is this example meant to demonstrate? -- Martin
Michael Wang
2002-Aug-18 19:12 UTC
Use "rsync --dry-run" to find directory difference, but ...
I would like to use "rsync --dry-run" option to compare two directories, make use the output programatically. However, besides the filelist, rsync also spits out some lines as shown below. And from version to version, the message is different. For example, in a newer version, we do not have "xxxx files to consider.", and no "^rsync: ". This makes excluding these lines difficult. Any advice? Thanks. -- rsync: building file list... rsync: 3154 files to consider. ... filelist ... wrote 65063 bytes read 20 bytes 43388.67 bytes/sec total size is 152420617 speedup is 2341.94 -- -- Michael Wang http://www.unixlabplus.com/