rsync --link-dest not working as expected with symlinks

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP












0















I'm using rsync to backup some of my files:



rsync -aEN --delete --link-dest="$CURR/" "$SOURCE/" "$NEW/"



The --link-dest option works fine with most files, but not with symlinks.

When I was writing a clean-up script for old backups, I noticed that unchanged symlinks are not hard-linked, but rather copied.



Now I'm wondering:

Is there a way to make rsync hard-link unchanged symlinks as well?

And if not: Is it intentional or a bug in rsync?



I'm using rsync version 3.1.1 on Mac OS 10.11.



Edit:



It seems to be a problem in Mac OS X. For some reason HFS+ seems not to support hard-links to symlinks.










share|improve this question
























  • The --copy-links option is probably what you want.

    – Thomas Dickey
    Jun 17 '16 at 14:33











  • I'm not sure you can create a hard link to a symbolic link...

    – Kusalananda
    Jun 17 '16 at 15:43











  • Sure, you cannot. But the --copy-links option copies the files to which the links point (which is as close as OP will get to what was intended).

    – Thomas Dickey
    Jun 17 '16 at 16:25















0















I'm using rsync to backup some of my files:



rsync -aEN --delete --link-dest="$CURR/" "$SOURCE/" "$NEW/"



The --link-dest option works fine with most files, but not with symlinks.

When I was writing a clean-up script for old backups, I noticed that unchanged symlinks are not hard-linked, but rather copied.



Now I'm wondering:

Is there a way to make rsync hard-link unchanged symlinks as well?

And if not: Is it intentional or a bug in rsync?



I'm using rsync version 3.1.1 on Mac OS 10.11.



Edit:



It seems to be a problem in Mac OS X. For some reason HFS+ seems not to support hard-links to symlinks.










share|improve this question
























  • The --copy-links option is probably what you want.

    – Thomas Dickey
    Jun 17 '16 at 14:33











  • I'm not sure you can create a hard link to a symbolic link...

    – Kusalananda
    Jun 17 '16 at 15:43











  • Sure, you cannot. But the --copy-links option copies the files to which the links point (which is as close as OP will get to what was intended).

    – Thomas Dickey
    Jun 17 '16 at 16:25













0












0








0








I'm using rsync to backup some of my files:



rsync -aEN --delete --link-dest="$CURR/" "$SOURCE/" "$NEW/"



The --link-dest option works fine with most files, but not with symlinks.

When I was writing a clean-up script for old backups, I noticed that unchanged symlinks are not hard-linked, but rather copied.



Now I'm wondering:

Is there a way to make rsync hard-link unchanged symlinks as well?

And if not: Is it intentional or a bug in rsync?



I'm using rsync version 3.1.1 on Mac OS 10.11.



Edit:



It seems to be a problem in Mac OS X. For some reason HFS+ seems not to support hard-links to symlinks.










share|improve this question
















I'm using rsync to backup some of my files:



rsync -aEN --delete --link-dest="$CURR/" "$SOURCE/" "$NEW/"



The --link-dest option works fine with most files, but not with symlinks.

When I was writing a clean-up script for old backups, I noticed that unchanged symlinks are not hard-linked, but rather copied.



Now I'm wondering:

Is there a way to make rsync hard-link unchanged symlinks as well?

And if not: Is it intentional or a bug in rsync?



I'm using rsync version 3.1.1 on Mac OS 10.11.



Edit:



It seems to be a problem in Mac OS X. For some reason HFS+ seems not to support hard-links to symlinks.







rsync symlink hard-link






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Jun 17 '16 at 16:08







Sven

















asked Jun 17 '16 at 14:25









SvenSven

64




64












  • The --copy-links option is probably what you want.

    – Thomas Dickey
    Jun 17 '16 at 14:33











  • I'm not sure you can create a hard link to a symbolic link...

    – Kusalananda
    Jun 17 '16 at 15:43











  • Sure, you cannot. But the --copy-links option copies the files to which the links point (which is as close as OP will get to what was intended).

    – Thomas Dickey
    Jun 17 '16 at 16:25

















  • The --copy-links option is probably what you want.

    – Thomas Dickey
    Jun 17 '16 at 14:33











  • I'm not sure you can create a hard link to a symbolic link...

    – Kusalananda
    Jun 17 '16 at 15:43











  • Sure, you cannot. But the --copy-links option copies the files to which the links point (which is as close as OP will get to what was intended).

    – Thomas Dickey
    Jun 17 '16 at 16:25
















The --copy-links option is probably what you want.

– Thomas Dickey
Jun 17 '16 at 14:33





The --copy-links option is probably what you want.

– Thomas Dickey
Jun 17 '16 at 14:33













I'm not sure you can create a hard link to a symbolic link...

– Kusalananda
Jun 17 '16 at 15:43





I'm not sure you can create a hard link to a symbolic link...

– Kusalananda
Jun 17 '16 at 15:43













Sure, you cannot. But the --copy-links option copies the files to which the links point (which is as close as OP will get to what was intended).

– Thomas Dickey
Jun 17 '16 at 16:25





Sure, you cannot. But the --copy-links option copies the files to which the links point (which is as close as OP will get to what was intended).

– Thomas Dickey
Jun 17 '16 at 16:25










2 Answers
2






active

oldest

votes


















3














The filesystem on macOS (HFS+) does not support hard links to symbolic links:



$ touch file
$ ls -l file
-rw-r--r-- 1 kk staff 0 Jun 17 18:35 file

$ ln -s file slink
$ ls -l file slink
-rw-r--r-- 1 kk staff 0 Jun 17 18:35 file
lrwxr-xr-x 1 kk staff 4 Jun 17 18:36 slink -> file


The following would ordinarily create a hard link to a symbolic link, and is even documented in the ln manual on macOS to do so (EDIT: no it isn't, unless you have GNU coreutils installed and read the wrong manual, doh!):



$ ln -P slink hlink
$ ls -l file slink hlink
-rw-r--r-- 1 kk staff 0 Jun 17 18:35 file
lrwxr-xr-x 1 kk staff 4 Jun 17 18:38 hlink -> file
lrwxr-xr-x 1 kk staff 4 Jun 17 18:36 slink -> file


You can see by the ref count (1) that no new name was created for slink (would have been 2 for both slink and hlink if it had worked). Also, stat tells us that hlink is a symbolic link with 1 inode link (not 2):



$ stat hlink
File: 'hlink' -> 'file'
Size: 4 Blocks: 8 IO Block: 4096 symbolic link
Device: 1000004h/16777220d Inode: 83828644 Links: 1
Access: (0755/lrwxr-xr-x) Uid: ( 501/ kk) Gid: ( 20/ staff)
Access: 2016-06-17 18:38:18.000000000 +0200
Modify: 2016-06-17 18:38:18.000000000 +0200
Change: 2016-06-17 18:38:18.000000000 +0200
Birth: 2016-06-17 18:38:18.000000000 +0200


EDIT: Since I was caught using GNU coreutils, here's the tests again with /bin/ln on macOS:



$ touch file
$ /bin/ln -s file slink
$ /bin/ln slink hlink # there is no option corresponding to GNU's -P
$ ls -l file slink hlink
-rw-r--r-- 2 kk staff 0 Jun 17 18:59 file
-rw-r--r-- 2 kk staff 0 Jun 17 18:59 hlink
lrwxr-xr-x 1 kk staff 4 Jun 17 18:59 slink -> file


The hard link is pointing to file rather than to slink.



On e.g. Linux and OpenBSD (the other OSes I use), it is possible to do this, which results in



$ ls -l file slink hlink
-rw-rw-r-- 1 kk kk 0 Jun 17 18:35 file
lrwxrwxrwx 2 kk kk 4 Jun 17 18:43 hlink -> file
lrwxrwxrwx 2 kk kk 4 Jun 17 18:43 slink -> file


(notice "2")






share|improve this answer




















  • 2





    That answers my question, thank you. Puzzles me why it isn't implementet, considering even hard-linking directories is implemented in HFS+.

    – Sven
    Jun 17 '16 at 17:36












  • Yeah, I thought that fact was a bit humorous too.

    – Kusalananda
    Jun 17 '16 at 17:40


















1














You cannot make hardlinks to symbolic links (this is not a "limitation" of OS X). A hardlink is a reference to an inode, and a symbolic link is not an inode but only an entry in the directory with some additional information.



You may be thinking of Windows, which has analogous features, which behave differently.



rsync does have a --copy-links option which tells it to copy the file to which a symbolic link points to the destination. That would be useful if you are trying to construct a complete replica of your source directory (but not very useful if your goal is to reduce disk usage).



  • What is the difference between symbolic and hard links?

  • Symlinks vs Hardlinks and how to create them


  • Hard Links and Junctions (Windows)


  • rsync - faster, flexible replacement for rcp

  • link, ln -- make links





share|improve this answer

























  • I believe you're wrong. See my answer.

    – Kusalananda
    Jun 17 '16 at 16:47






  • 1





    My bad. It turns out I had the GNU coreutils installed. That's where that manual comes from. Still, I can create a hard link to a symbolic link on other OSes...

    – Kusalananda
    Jun 17 '16 at 16:56







  • 3





    It's a recent feature in POSIX, which doesn't appear to be documented for OSX. rsync isn't in POSIX, doesn't have to support new features.

    – Thomas Dickey
    Jun 17 '16 at 17:02







  • 1





    I don't see why it shouldn't be possible to create hard-links to symlinks. Anyway I just tested it on Linux and it worked fine. As for Windows, I don't know what features it offers. I've avoided it for the last 14 or so years.

    – Sven
    Jun 17 '16 at 17:11







  • 1





    It depends. The rsync program takes it into account (see log entry).

    – Thomas Dickey
    Jun 17 '16 at 17:24











Your Answer








StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "106"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f290420%2frsync-link-dest-not-working-as-expected-with-symlinks%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























2 Answers
2






active

oldest

votes








2 Answers
2






active

oldest

votes









active

oldest

votes






active

oldest

votes









3














The filesystem on macOS (HFS+) does not support hard links to symbolic links:



$ touch file
$ ls -l file
-rw-r--r-- 1 kk staff 0 Jun 17 18:35 file

$ ln -s file slink
$ ls -l file slink
-rw-r--r-- 1 kk staff 0 Jun 17 18:35 file
lrwxr-xr-x 1 kk staff 4 Jun 17 18:36 slink -> file


The following would ordinarily create a hard link to a symbolic link, and is even documented in the ln manual on macOS to do so (EDIT: no it isn't, unless you have GNU coreutils installed and read the wrong manual, doh!):



$ ln -P slink hlink
$ ls -l file slink hlink
-rw-r--r-- 1 kk staff 0 Jun 17 18:35 file
lrwxr-xr-x 1 kk staff 4 Jun 17 18:38 hlink -> file
lrwxr-xr-x 1 kk staff 4 Jun 17 18:36 slink -> file


You can see by the ref count (1) that no new name was created for slink (would have been 2 for both slink and hlink if it had worked). Also, stat tells us that hlink is a symbolic link with 1 inode link (not 2):



$ stat hlink
File: 'hlink' -> 'file'
Size: 4 Blocks: 8 IO Block: 4096 symbolic link
Device: 1000004h/16777220d Inode: 83828644 Links: 1
Access: (0755/lrwxr-xr-x) Uid: ( 501/ kk) Gid: ( 20/ staff)
Access: 2016-06-17 18:38:18.000000000 +0200
Modify: 2016-06-17 18:38:18.000000000 +0200
Change: 2016-06-17 18:38:18.000000000 +0200
Birth: 2016-06-17 18:38:18.000000000 +0200


EDIT: Since I was caught using GNU coreutils, here's the tests again with /bin/ln on macOS:



$ touch file
$ /bin/ln -s file slink
$ /bin/ln slink hlink # there is no option corresponding to GNU's -P
$ ls -l file slink hlink
-rw-r--r-- 2 kk staff 0 Jun 17 18:59 file
-rw-r--r-- 2 kk staff 0 Jun 17 18:59 hlink
lrwxr-xr-x 1 kk staff 4 Jun 17 18:59 slink -> file


The hard link is pointing to file rather than to slink.



On e.g. Linux and OpenBSD (the other OSes I use), it is possible to do this, which results in



$ ls -l file slink hlink
-rw-rw-r-- 1 kk kk 0 Jun 17 18:35 file
lrwxrwxrwx 2 kk kk 4 Jun 17 18:43 hlink -> file
lrwxrwxrwx 2 kk kk 4 Jun 17 18:43 slink -> file


(notice "2")






share|improve this answer




















  • 2





    That answers my question, thank you. Puzzles me why it isn't implementet, considering even hard-linking directories is implemented in HFS+.

    – Sven
    Jun 17 '16 at 17:36












  • Yeah, I thought that fact was a bit humorous too.

    – Kusalananda
    Jun 17 '16 at 17:40















3














The filesystem on macOS (HFS+) does not support hard links to symbolic links:



$ touch file
$ ls -l file
-rw-r--r-- 1 kk staff 0 Jun 17 18:35 file

$ ln -s file slink
$ ls -l file slink
-rw-r--r-- 1 kk staff 0 Jun 17 18:35 file
lrwxr-xr-x 1 kk staff 4 Jun 17 18:36 slink -> file


The following would ordinarily create a hard link to a symbolic link, and is even documented in the ln manual on macOS to do so (EDIT: no it isn't, unless you have GNU coreutils installed and read the wrong manual, doh!):



$ ln -P slink hlink
$ ls -l file slink hlink
-rw-r--r-- 1 kk staff 0 Jun 17 18:35 file
lrwxr-xr-x 1 kk staff 4 Jun 17 18:38 hlink -> file
lrwxr-xr-x 1 kk staff 4 Jun 17 18:36 slink -> file


You can see by the ref count (1) that no new name was created for slink (would have been 2 for both slink and hlink if it had worked). Also, stat tells us that hlink is a symbolic link with 1 inode link (not 2):



$ stat hlink
File: 'hlink' -> 'file'
Size: 4 Blocks: 8 IO Block: 4096 symbolic link
Device: 1000004h/16777220d Inode: 83828644 Links: 1
Access: (0755/lrwxr-xr-x) Uid: ( 501/ kk) Gid: ( 20/ staff)
Access: 2016-06-17 18:38:18.000000000 +0200
Modify: 2016-06-17 18:38:18.000000000 +0200
Change: 2016-06-17 18:38:18.000000000 +0200
Birth: 2016-06-17 18:38:18.000000000 +0200


EDIT: Since I was caught using GNU coreutils, here's the tests again with /bin/ln on macOS:



$ touch file
$ /bin/ln -s file slink
$ /bin/ln slink hlink # there is no option corresponding to GNU's -P
$ ls -l file slink hlink
-rw-r--r-- 2 kk staff 0 Jun 17 18:59 file
-rw-r--r-- 2 kk staff 0 Jun 17 18:59 hlink
lrwxr-xr-x 1 kk staff 4 Jun 17 18:59 slink -> file


The hard link is pointing to file rather than to slink.



On e.g. Linux and OpenBSD (the other OSes I use), it is possible to do this, which results in



$ ls -l file slink hlink
-rw-rw-r-- 1 kk kk 0 Jun 17 18:35 file
lrwxrwxrwx 2 kk kk 4 Jun 17 18:43 hlink -> file
lrwxrwxrwx 2 kk kk 4 Jun 17 18:43 slink -> file


(notice "2")






share|improve this answer




















  • 2





    That answers my question, thank you. Puzzles me why it isn't implementet, considering even hard-linking directories is implemented in HFS+.

    – Sven
    Jun 17 '16 at 17:36












  • Yeah, I thought that fact was a bit humorous too.

    – Kusalananda
    Jun 17 '16 at 17:40













3












3








3







The filesystem on macOS (HFS+) does not support hard links to symbolic links:



$ touch file
$ ls -l file
-rw-r--r-- 1 kk staff 0 Jun 17 18:35 file

$ ln -s file slink
$ ls -l file slink
-rw-r--r-- 1 kk staff 0 Jun 17 18:35 file
lrwxr-xr-x 1 kk staff 4 Jun 17 18:36 slink -> file


The following would ordinarily create a hard link to a symbolic link, and is even documented in the ln manual on macOS to do so (EDIT: no it isn't, unless you have GNU coreutils installed and read the wrong manual, doh!):



$ ln -P slink hlink
$ ls -l file slink hlink
-rw-r--r-- 1 kk staff 0 Jun 17 18:35 file
lrwxr-xr-x 1 kk staff 4 Jun 17 18:38 hlink -> file
lrwxr-xr-x 1 kk staff 4 Jun 17 18:36 slink -> file


You can see by the ref count (1) that no new name was created for slink (would have been 2 for both slink and hlink if it had worked). Also, stat tells us that hlink is a symbolic link with 1 inode link (not 2):



$ stat hlink
File: 'hlink' -> 'file'
Size: 4 Blocks: 8 IO Block: 4096 symbolic link
Device: 1000004h/16777220d Inode: 83828644 Links: 1
Access: (0755/lrwxr-xr-x) Uid: ( 501/ kk) Gid: ( 20/ staff)
Access: 2016-06-17 18:38:18.000000000 +0200
Modify: 2016-06-17 18:38:18.000000000 +0200
Change: 2016-06-17 18:38:18.000000000 +0200
Birth: 2016-06-17 18:38:18.000000000 +0200


EDIT: Since I was caught using GNU coreutils, here's the tests again with /bin/ln on macOS:



$ touch file
$ /bin/ln -s file slink
$ /bin/ln slink hlink # there is no option corresponding to GNU's -P
$ ls -l file slink hlink
-rw-r--r-- 2 kk staff 0 Jun 17 18:59 file
-rw-r--r-- 2 kk staff 0 Jun 17 18:59 hlink
lrwxr-xr-x 1 kk staff 4 Jun 17 18:59 slink -> file


The hard link is pointing to file rather than to slink.



On e.g. Linux and OpenBSD (the other OSes I use), it is possible to do this, which results in



$ ls -l file slink hlink
-rw-rw-r-- 1 kk kk 0 Jun 17 18:35 file
lrwxrwxrwx 2 kk kk 4 Jun 17 18:43 hlink -> file
lrwxrwxrwx 2 kk kk 4 Jun 17 18:43 slink -> file


(notice "2")






share|improve this answer















The filesystem on macOS (HFS+) does not support hard links to symbolic links:



$ touch file
$ ls -l file
-rw-r--r-- 1 kk staff 0 Jun 17 18:35 file

$ ln -s file slink
$ ls -l file slink
-rw-r--r-- 1 kk staff 0 Jun 17 18:35 file
lrwxr-xr-x 1 kk staff 4 Jun 17 18:36 slink -> file


The following would ordinarily create a hard link to a symbolic link, and is even documented in the ln manual on macOS to do so (EDIT: no it isn't, unless you have GNU coreutils installed and read the wrong manual, doh!):



$ ln -P slink hlink
$ ls -l file slink hlink
-rw-r--r-- 1 kk staff 0 Jun 17 18:35 file
lrwxr-xr-x 1 kk staff 4 Jun 17 18:38 hlink -> file
lrwxr-xr-x 1 kk staff 4 Jun 17 18:36 slink -> file


You can see by the ref count (1) that no new name was created for slink (would have been 2 for both slink and hlink if it had worked). Also, stat tells us that hlink is a symbolic link with 1 inode link (not 2):



$ stat hlink
File: 'hlink' -> 'file'
Size: 4 Blocks: 8 IO Block: 4096 symbolic link
Device: 1000004h/16777220d Inode: 83828644 Links: 1
Access: (0755/lrwxr-xr-x) Uid: ( 501/ kk) Gid: ( 20/ staff)
Access: 2016-06-17 18:38:18.000000000 +0200
Modify: 2016-06-17 18:38:18.000000000 +0200
Change: 2016-06-17 18:38:18.000000000 +0200
Birth: 2016-06-17 18:38:18.000000000 +0200


EDIT: Since I was caught using GNU coreutils, here's the tests again with /bin/ln on macOS:



$ touch file
$ /bin/ln -s file slink
$ /bin/ln slink hlink # there is no option corresponding to GNU's -P
$ ls -l file slink hlink
-rw-r--r-- 2 kk staff 0 Jun 17 18:59 file
-rw-r--r-- 2 kk staff 0 Jun 17 18:59 hlink
lrwxr-xr-x 1 kk staff 4 Jun 17 18:59 slink -> file


The hard link is pointing to file rather than to slink.



On e.g. Linux and OpenBSD (the other OSes I use), it is possible to do this, which results in



$ ls -l file slink hlink
-rw-rw-r-- 1 kk kk 0 Jun 17 18:35 file
lrwxrwxrwx 2 kk kk 4 Jun 17 18:43 hlink -> file
lrwxrwxrwx 2 kk kk 4 Jun 17 18:43 slink -> file


(notice "2")







share|improve this answer














share|improve this answer



share|improve this answer








edited Mar 1 at 10:18

























answered Jun 17 '16 at 16:42









KusalanandaKusalananda

138k17258426




138k17258426







  • 2





    That answers my question, thank you. Puzzles me why it isn't implementet, considering even hard-linking directories is implemented in HFS+.

    – Sven
    Jun 17 '16 at 17:36












  • Yeah, I thought that fact was a bit humorous too.

    – Kusalananda
    Jun 17 '16 at 17:40












  • 2





    That answers my question, thank you. Puzzles me why it isn't implementet, considering even hard-linking directories is implemented in HFS+.

    – Sven
    Jun 17 '16 at 17:36












  • Yeah, I thought that fact was a bit humorous too.

    – Kusalananda
    Jun 17 '16 at 17:40







2




2





That answers my question, thank you. Puzzles me why it isn't implementet, considering even hard-linking directories is implemented in HFS+.

– Sven
Jun 17 '16 at 17:36






That answers my question, thank you. Puzzles me why it isn't implementet, considering even hard-linking directories is implemented in HFS+.

– Sven
Jun 17 '16 at 17:36














Yeah, I thought that fact was a bit humorous too.

– Kusalananda
Jun 17 '16 at 17:40





Yeah, I thought that fact was a bit humorous too.

– Kusalananda
Jun 17 '16 at 17:40













1














You cannot make hardlinks to symbolic links (this is not a "limitation" of OS X). A hardlink is a reference to an inode, and a symbolic link is not an inode but only an entry in the directory with some additional information.



You may be thinking of Windows, which has analogous features, which behave differently.



rsync does have a --copy-links option which tells it to copy the file to which a symbolic link points to the destination. That would be useful if you are trying to construct a complete replica of your source directory (but not very useful if your goal is to reduce disk usage).



  • What is the difference between symbolic and hard links?

  • Symlinks vs Hardlinks and how to create them


  • Hard Links and Junctions (Windows)


  • rsync - faster, flexible replacement for rcp

  • link, ln -- make links





share|improve this answer

























  • I believe you're wrong. See my answer.

    – Kusalananda
    Jun 17 '16 at 16:47






  • 1





    My bad. It turns out I had the GNU coreutils installed. That's where that manual comes from. Still, I can create a hard link to a symbolic link on other OSes...

    – Kusalananda
    Jun 17 '16 at 16:56







  • 3





    It's a recent feature in POSIX, which doesn't appear to be documented for OSX. rsync isn't in POSIX, doesn't have to support new features.

    – Thomas Dickey
    Jun 17 '16 at 17:02







  • 1





    I don't see why it shouldn't be possible to create hard-links to symlinks. Anyway I just tested it on Linux and it worked fine. As for Windows, I don't know what features it offers. I've avoided it for the last 14 or so years.

    – Sven
    Jun 17 '16 at 17:11







  • 1





    It depends. The rsync program takes it into account (see log entry).

    – Thomas Dickey
    Jun 17 '16 at 17:24















1














You cannot make hardlinks to symbolic links (this is not a "limitation" of OS X). A hardlink is a reference to an inode, and a symbolic link is not an inode but only an entry in the directory with some additional information.



You may be thinking of Windows, which has analogous features, which behave differently.



rsync does have a --copy-links option which tells it to copy the file to which a symbolic link points to the destination. That would be useful if you are trying to construct a complete replica of your source directory (but not very useful if your goal is to reduce disk usage).



  • What is the difference between symbolic and hard links?

  • Symlinks vs Hardlinks and how to create them


  • Hard Links and Junctions (Windows)


  • rsync - faster, flexible replacement for rcp

  • link, ln -- make links





share|improve this answer

























  • I believe you're wrong. See my answer.

    – Kusalananda
    Jun 17 '16 at 16:47






  • 1





    My bad. It turns out I had the GNU coreutils installed. That's where that manual comes from. Still, I can create a hard link to a symbolic link on other OSes...

    – Kusalananda
    Jun 17 '16 at 16:56







  • 3





    It's a recent feature in POSIX, which doesn't appear to be documented for OSX. rsync isn't in POSIX, doesn't have to support new features.

    – Thomas Dickey
    Jun 17 '16 at 17:02







  • 1





    I don't see why it shouldn't be possible to create hard-links to symlinks. Anyway I just tested it on Linux and it worked fine. As for Windows, I don't know what features it offers. I've avoided it for the last 14 or so years.

    – Sven
    Jun 17 '16 at 17:11







  • 1





    It depends. The rsync program takes it into account (see log entry).

    – Thomas Dickey
    Jun 17 '16 at 17:24













1












1








1







You cannot make hardlinks to symbolic links (this is not a "limitation" of OS X). A hardlink is a reference to an inode, and a symbolic link is not an inode but only an entry in the directory with some additional information.



You may be thinking of Windows, which has analogous features, which behave differently.



rsync does have a --copy-links option which tells it to copy the file to which a symbolic link points to the destination. That would be useful if you are trying to construct a complete replica of your source directory (but not very useful if your goal is to reduce disk usage).



  • What is the difference between symbolic and hard links?

  • Symlinks vs Hardlinks and how to create them


  • Hard Links and Junctions (Windows)


  • rsync - faster, flexible replacement for rcp

  • link, ln -- make links





share|improve this answer















You cannot make hardlinks to symbolic links (this is not a "limitation" of OS X). A hardlink is a reference to an inode, and a symbolic link is not an inode but only an entry in the directory with some additional information.



You may be thinking of Windows, which has analogous features, which behave differently.



rsync does have a --copy-links option which tells it to copy the file to which a symbolic link points to the destination. That would be useful if you are trying to construct a complete replica of your source directory (but not very useful if your goal is to reduce disk usage).



  • What is the difference between symbolic and hard links?

  • Symlinks vs Hardlinks and how to create them


  • Hard Links and Junctions (Windows)


  • rsync - faster, flexible replacement for rcp

  • link, ln -- make links






share|improve this answer














share|improve this answer



share|improve this answer








edited Apr 13 '17 at 12:36









Community

1




1










answered Jun 17 '16 at 16:41









Thomas DickeyThomas Dickey

54k5105178




54k5105178












  • I believe you're wrong. See my answer.

    – Kusalananda
    Jun 17 '16 at 16:47






  • 1





    My bad. It turns out I had the GNU coreutils installed. That's where that manual comes from. Still, I can create a hard link to a symbolic link on other OSes...

    – Kusalananda
    Jun 17 '16 at 16:56







  • 3





    It's a recent feature in POSIX, which doesn't appear to be documented for OSX. rsync isn't in POSIX, doesn't have to support new features.

    – Thomas Dickey
    Jun 17 '16 at 17:02







  • 1





    I don't see why it shouldn't be possible to create hard-links to symlinks. Anyway I just tested it on Linux and it worked fine. As for Windows, I don't know what features it offers. I've avoided it for the last 14 or so years.

    – Sven
    Jun 17 '16 at 17:11







  • 1





    It depends. The rsync program takes it into account (see log entry).

    – Thomas Dickey
    Jun 17 '16 at 17:24

















  • I believe you're wrong. See my answer.

    – Kusalananda
    Jun 17 '16 at 16:47






  • 1





    My bad. It turns out I had the GNU coreutils installed. That's where that manual comes from. Still, I can create a hard link to a symbolic link on other OSes...

    – Kusalananda
    Jun 17 '16 at 16:56







  • 3





    It's a recent feature in POSIX, which doesn't appear to be documented for OSX. rsync isn't in POSIX, doesn't have to support new features.

    – Thomas Dickey
    Jun 17 '16 at 17:02







  • 1





    I don't see why it shouldn't be possible to create hard-links to symlinks. Anyway I just tested it on Linux and it worked fine. As for Windows, I don't know what features it offers. I've avoided it for the last 14 or so years.

    – Sven
    Jun 17 '16 at 17:11







  • 1





    It depends. The rsync program takes it into account (see log entry).

    – Thomas Dickey
    Jun 17 '16 at 17:24
















I believe you're wrong. See my answer.

– Kusalananda
Jun 17 '16 at 16:47





I believe you're wrong. See my answer.

– Kusalananda
Jun 17 '16 at 16:47




1




1





My bad. It turns out I had the GNU coreutils installed. That's where that manual comes from. Still, I can create a hard link to a symbolic link on other OSes...

– Kusalananda
Jun 17 '16 at 16:56






My bad. It turns out I had the GNU coreutils installed. That's where that manual comes from. Still, I can create a hard link to a symbolic link on other OSes...

– Kusalananda
Jun 17 '16 at 16:56





3




3





It's a recent feature in POSIX, which doesn't appear to be documented for OSX. rsync isn't in POSIX, doesn't have to support new features.

– Thomas Dickey
Jun 17 '16 at 17:02






It's a recent feature in POSIX, which doesn't appear to be documented for OSX. rsync isn't in POSIX, doesn't have to support new features.

– Thomas Dickey
Jun 17 '16 at 17:02





1




1





I don't see why it shouldn't be possible to create hard-links to symlinks. Anyway I just tested it on Linux and it worked fine. As for Windows, I don't know what features it offers. I've avoided it for the last 14 or so years.

– Sven
Jun 17 '16 at 17:11






I don't see why it shouldn't be possible to create hard-links to symlinks. Anyway I just tested it on Linux and it worked fine. As for Windows, I don't know what features it offers. I've avoided it for the last 14 or so years.

– Sven
Jun 17 '16 at 17:11





1




1





It depends. The rsync program takes it into account (see log entry).

– Thomas Dickey
Jun 17 '16 at 17:24





It depends. The rsync program takes it into account (see log entry).

– Thomas Dickey
Jun 17 '16 at 17:24

















draft saved

draft discarded
















































Thanks for contributing an answer to Unix & Linux Stack Exchange!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f290420%2frsync-link-dest-not-working-as-expected-with-symlinks%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown






Popular posts from this blog

Peggy Mitchell

Palaiologos

The Forum (Inglewood, California)