Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hardlinked symlinks are not supported #2379

Closed
ThomasWaldmann opened this issue Apr 2, 2017 · 6 comments
Closed

hardlinked symlinks are not supported #2379

ThomasWaldmann opened this issue Apr 2, 2017 · 6 comments
Assignees

Comments

@ThomasWaldmann
Copy link
Member

ThomasWaldmann commented Apr 2, 2017

borg supports hardlinks and it supports symlinks and both are backupped as it should be.

A problem are "hardlinked symlinks".

# on macOS 12
% touch target
% ln -s target symlink1
% ln -P symlink1 symlink2
% ls -li             
40490316 lrwxr-xr-x  2 tw  staff  6 May 11 12:32 symlink1 -> target
40490316 lrwxr-xr-x  2 tw  staff  6 May 11 12:32 symlink2 -> target
40490309 -rw-r--r--  1 tw  staff  0 May 11 12:31 target

This part of #2324 is not addressed yet (except that symlinks are not in the documented list of supported hardlinked fs objects).

The problem here is the dual-use of item.source (see #2343), which should be solved first.

Then, hardlinked symlinks could be supported in same way as other hardlinked fs objects.

Note:

  • This is a minor issue, likely nobody uses hardlinked symlinks anyway.
  • If somebody uses them, the only negative effect is that such hardlinks are not archived as hardlinks (and thus: not restored as hardlinks).
@ThomasWaldmann ThomasWaldmann added this to the 1.1.0b5 milestone Apr 2, 2017
@enkore
Copy link
Contributor

enkore commented Apr 2, 2017

  • Since permissions on symlinks are ignored and symlinks cannot be changed after creation, the usual benefits of hardlinks don't apply. The only observable effect is st_nlink (and one less inode used).

@ThomasWaldmann ThomasWaldmann removed this from the 1.1.0b5 milestone Apr 3, 2017
@yash-fn
Copy link

yash-fn commented Oct 6, 2021

so given its a hardlink to a symlink, the only tangible benefit would be that when one of the symlinks is overwritten to point elsewhere the other one would similarly be updated to point to the new location as well, as normal hard links work. But I tested this on my system using ln -sf (which as far as I'm aware is the only way to change a symlink without deleting first) and it appears that ln will first delete then write breaking any hardlink on the symlink anyways. Thus, if by itself this functionality is not present, perhaps this issue can be safely ignored altogether since separate inodes see to function the exact same as hardlinking them. Right? And disk size is irrelevant when talking about links.

In other words, unless I am mistaken and please correct me if I am, there is no way to 'edit' a symlink other than to delete it first then create a new one with a new innode. Borg would only make sense include this feature if there is a way to change the symlink while preserving the innode and there appears to none.

I do not know, however, if this applied to mknod/devices however. But it appears symlinks are pretty safe to ignore.

@borgbackup borgbackup deleted a comment from nilsmeyer May 11, 2022
@borgbackup borgbackup deleted a comment from BarbzYHOOL May 11, 2022
@borgbackup borgbackup deleted a comment from BarbzYHOOL May 11, 2022
@borgbackup borgbackup deleted a comment from BarbzYHOOL May 11, 2022
@ThomasWaldmann ThomasWaldmann self-assigned this May 11, 2022
@ThomasWaldmann
Copy link
Member Author

Working on this in #6663.

Since that uses item.hlid to relate hardlinks, there is no issue with usage of item.source any more.

ThomasWaldmann added a commit to ThomasWaldmann/borg that referenced this issue May 11, 2022
as we use item.hlid now to group hardlinks together,
there is no conflict with the item.source usage for
symlink targets any more.
ThomasWaldmann added a commit to ThomasWaldmann/borg that referenced this issue May 16, 2022
as we use item.hlid now to group hardlinks together,
there is no conflict with the item.source usage for
symlink targets any more.
ThomasWaldmann added a commit to ThomasWaldmann/borg that referenced this issue May 17, 2022
borg now has the chunks list in every item with content.
due to the symmetric way how borg now deals with hardlinks using
item.hlid, processing gets much simpler.

but some places where borg deals with other "sources" of hardlinks
still need to do some hardlink management:
borg uses the HardLinkManager there now (which is not much more
than a dict, but keeps documentation at one place and avoids some
code duplication we had before).

item.hlid is computed via hardlink_id function.

support hardlinked symlinks, fixes borgbackup#2379
as we use item.hlid now to group hardlinks together,
there is no conflict with the item.source usage for
symlink targets any more.

2nd+ hardlinks now add to the files count as did the 1st one.
for borg, now all hardlinks are created equal.
so any hardlink item with chunks now adds to the "file" count.

ItemFormatter: support {hlid} instead of {source} for hardlinks
ThomasWaldmann added a commit to ThomasWaldmann/borg that referenced this issue May 18, 2022
borg now has the chunks list in every item with content.
due to the symmetric way how borg now deals with hardlinks using
item.hlid, processing gets much simpler.

but some places where borg deals with other "sources" of hardlinks
still need to do some hardlink management:
borg uses the HardLinkManager there now (which is not much more
than a dict, but keeps documentation at one place and avoids some
code duplication we had before).

item.hlid is computed via hardlink_id function.

support hardlinked symlinks, fixes borgbackup#2379
as we use item.hlid now to group hardlinks together,
there is no conflict with the item.source usage for
symlink targets any more.

2nd+ hardlinks now add to the files count as did the 1st one.
for borg, now all hardlinks are created equal.
so any hardlink item with chunks now adds to the "file" count.

ItemFormatter: support {hlid} instead of {source} for hardlinks
@ThomasWaldmann
Copy link
Member Author

borg2 branch supports hardlinked symlinks.

@prahal
Copy link

prahal commented May 12, 2024

Is this fixed in borg 1.2? Maybe the FAQ should be updated to stop advertising hardlinked symlinks are not supported?

For hardlinked symlinks, the hardlinking can not be archived (and thus, the hardlinking will not be done at extraction time). The symlinks will be archived and extracted as non-hardlinked symlinks, see #2379.

EDIT: sorry I finally found that borg2 is indeed borg v2 the current master branch in beta. This FAQ section thus still holds.

@ThomasWaldmann
Copy link
Member Author

This is rather a design limitation of the borg item metadata (in borg < 2) than a bug. It's fixed in master branch, which will be released as borg 2 at some time in the future.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants