Find the answer to your Linux question:
Results 1 to 7 of 7
Code: $ cd /tmp $ echo "123" > aaa $ echo "123" > bbb $ echo ln -s bbb ccc $ echo ls -la aaa bbb ccc -> bbb $ ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Sep 2007
    Posts
    7

    rsync symlinks issue


    Code:
    $ cd /tmp
    $ echo "123" > aaa
    $ echo "123" > bbb
    $ echo ln -s bbb ccc
    $ echo ls -la
    aaa
    bbb
    ccc -> bbb
    $ rsync aaa ccc
    $ echo ls -la
    aaa
    bbb
    ccc
    This example shows that symlink ccc was replaced with a regular file, which implies that during a remote sync the contents of the aaa will be downloaded. However, files aaa and bbb have the same content, so I need rsync to skip updating the destination file if it is a symlink that points to a file that is identical to the source file. The rsync manpage has some stuff about symlinks, but I found only arguments related to symlinks on source, not on destination. Any hints about changing rsync behaviour to suit my needs?

  2. #2
    Linux Enthusiast likwid's Avatar
    Join Date
    Dec 2006
    Location
    MA
    Posts
    649
    I use rsync with -avrP and it preserves links, I think P is the switch that does it.

  3. #3
    Linux Enthusiast likwid's Avatar
    Join Date
    Dec 2006
    Location
    MA
    Posts
    649
    After reading this over, I don't know exactly what you're trying to do. Looks like normal behavior.

  4. $spacer_open
    $spacer_close
  5. #4
    Just Joined!
    Join Date
    Sep 2007
    Posts
    7
    Quote Originally Posted by likwid View Post
    I use rsync with -avrP and it preserves links, I think P is the switch that does it.
    Excuse me, -P doesn't have anything to do with symlinks.

  6. #5
    Just Joined!
    Join Date
    Sep 2007
    Posts
    7
    Quote Originally Posted by likwid View Post
    After reading this over, I don't know exactly what you're trying to do.
    Heh, actually I was trying to provide a trivial example, to make the understanding easier. Here's the deal. I have two directory trees. Big ones. They have many common/identical files (relative to the roots of the trees). So I was thinking that I could save hdd space by replacing identical files in one of these directory trees with symlinks from the other tree. But the problem is each of these trees are periodically synced individually with an external source. My example was a proof that during a sync, all the symlinks will be replaced with files. That'll eat all the space again, which is a thing I want to avoid.

    Feel free to ask more questions about my issue, if you're still confused.

  7. #6
    Linux Enthusiast likwid's Avatar
    Join Date
    Dec 2006
    Location
    MA
    Posts
    649
    Quote Originally Posted by opensourcefan View Post
    Excuse me, -P doesn't have anything to do with symlinks.
    Excuse me, for not checking the man pages before taking a guess.

  8. #7
    Just Joined!
    Join Date
    Jun 2010
    Location
    Near Durham, NC
    Posts
    1
    I came upon the same need: copy files from source to destination, but if it finds a link at the destination don't overwrite it if the link points to a file whose contents are the same as the source.

    Couldn't find a way to do it, either. I think it's not (yet) a feature.

Posting Permissions

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