--copy-unsafe-links does not work for "double" symlinks

Roland Koebler r.koebler at yahoo.de
Mon Oct 5 17:47:39 MDT 2009


as documented, if you use rsync with --copy-unsafe-links, and copy a
directory with a symlink pointing outside of the copied tree, the
referent of the symlink is copied.

Now, assume that the directory contains a symlink, which points to a
(2nd) directory outside of the copied tree.
If this (2nd) directory contains another symlink, which also points outside
of the copied tree, rsync unfortunately only copies this symlink and *not*
the referent.

I don't know if this is a rsync-problem or a symlink-problem.

(rsync  version 3.0.3  protocol version 30, on Debian Lenny)


- host 1 directory-structure ("empty"):
    drwx------ ./1

- host 2 directory-structure:
    drwx------ ./2
    -rw------- ./2/file
    lrwxrwxrwx ./2/dir -> ../foo
    drwx------ ./foo
    -rw------- ./foo/foofile
    lrwxrwxrwx ./foo/bar -> ../bar
    drwx------ ./bar
    -rw------- ./bar/barfile

- mirror host 2 to host 1:
    $ rsync -av --copy-unsafe-links 2/ 1/
    sending incremental file list
    dir/bar -> ../bar/

    sent 206 bytes  received 60 bytes  532.00 bytes/sec
    total size is 7  speedup is 0.03

Now, host 1 contains:
    drwx------ ./1
    -rw------- ./1/file
    drwx------ ./1/dir
    -rw------- ./1/dir/foofile
    lrwxrwxrws ./1/dir/bar -> ../bar
"file", "dir" and "foofile" are ok; but "bar" is a dangling symlink, and
"barfile" was not copied.

I would have expected that host 1 would contain:
    drwx------ ./1
    -rw------- ./1/file
    drwx------ ./1/dir
    -rw------- ./1/dir/foofile
    drwx------ ./1/dir/bar/
    -rw------- ./1/dir/bar/barfile
But this is not the case.

Is this a bug, or did I miss something?


More information about the rsync mailing list