Find the answer to your Linux question:
Results 1 to 3 of 3
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1

    Rsync strange behaviour with symlinks


    Hello,
    Currently using rsync, I noticed a strange behaviour with symlinks.
    I'm using version 3.0.9 (last version is 3.1.1 but I don't intend to upgrade rsync specifically).

    In man pages, one can read :
    --links --copy-unsafe-links
    Turn all unsafe symlinks into files and duplicate all safe symlinks.
    and I also noticed the difference when having a trailing slash or not :
    A trailing slash on the source changes this behavior to avoid creating an additional directory level at the destination.
    You can think of a trailing / on a source as meaning "copy the contents of this directory" as opposed to "copy the directory by name", but in both cases the attributes of the containing directory are transferred to the containing directory on the destination. In other words, each of the following commands copies the files in the same way, including their setting of the attributes of /dest/foo:
    rsync -av /src/foo /dest
    rsync -av /src/foo/ /dest/foo
    However, I noticed that a symlink targeting outside the source folder can be considered as safe:
    Code:
    $ tree
    .
    ├── faraway
    │   └── farawayFile
    └── sandbox
        ├── dest
        ├── extern
        │   └── outsideFile
        └── src
            ├── insideFile
            ├── linkedFile1 -> ../../faraway/farawayFile
            └── linkedFile2 -> ../extern/outsideFile
    
    5 directories, 5 files
    
    sandbox$ rsync -iia -n --links --copy-unsafe-links src/ dest/
    .d..t...... ./
    >f+++++++++ insideFile
    >f+++++++++ linkedFile1
    >f+++++++++ linkedFile2
    
    sandbox$ rsync -iia -n --links --copy-unsafe-links src dest/
    cd+++++++++ src/
    >f+++++++++ src/insideFile
    >f+++++++++ src/linkedFile1
    cL+++++++++ src/linkedFile2 -> ../extern/outsideFile
    After running the last command, I end up with a broken link in destination folder :
    Code:
    $ tree
    .
    ├── faraway
    │   └── farawayFile
    └── sandbox
        ├── dest
        │   └── src
        │       ├── insideFile
        │       ├── linkedFile1
        │       └── linkedFile2 -> ../extern/outsideFile
        ├── extern
        │   └── outsideFile
        └── src
            ├── insideFile
            ├── linkedFile1 -> ../../faraway/farawayFile
            └── linkedFile2 -> ../extern/outsideFile
    I feel like it's a bug in rsync, do you agree ?

  2. #2
    Can you tell us what exact command you used for this?

  3. #3
    -->
    Hello,
    I had a directory named RsyncTest populated as follows :
    Code:
    .
    ├── faraway
    │   └── farawayFile
    └── sandbox
        ├── dest
        ├── extern
        │   └── outsideFile
        └── src
            ├── insideFile
            ├── linkedFile1 -> ../../faraway/farawayFile
            └── linkedFile2 -> ../extern/outsideFile
    Then from within the directory named sandbox, I ran
    Code:
    rsync -a --links --copy-unsafe-links src dest/
    and obtained a file
    Code:
    sandbox/dest/src/linkedFile2 -> ../extern/outsideFile
    which is a broken link

$spacer_open
$spacer_close

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •