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

Add follow options for symbolic links #3848

Closed
wants to merge 0 commits into from
Closed

Conversation

cccapon
Copy link

@cccapon cccapon commented Aug 2, 2022

In the Windows environment, the new 'follow' options allow symbolic links to be identified with a pattern.
When a symbolic link matches the pattern, restic will backup the link destination rather than the link itself.

The 'follow' options code is modelled after the 'exclude' options.

What does this PR change? What problem does it solve?

Under Windows, restic does not currently back up folders linked to by symbolic links.

This change allows users to select symbolic links by pattern matches (in an identical fashion with -exclude). Any symbolic link encountered will be compared with the patterns. If they match, then rather than looking at the symbolic link, restic will look at the underlying folder instead.

The default processing of restic does not change and unless these options are used, symbolic links will still be ignored.

Was the change previously discussed in an issue or on the forum?

#3594
#3594

Checklist

  • I have read the contribution guidelines.
  • I have enabled maintainer edits.
  • I have added tests for all code changes.
  • I have added documentation for relevant changes (in the manual).
  • There's a new file in changelog/unreleased/ that describes the changes for our users (see template).
  • I have run gofmt on the code in all commits.
  • All commit messages are formatted in the same style as the other commits in the repo.
  • I'm done! This pull request is ready for review.

@MichaelEischer
Copy link
Member

Hmm, I'm not particularly convinced by that option (or rather the four of them). Having to precisely specify each symlink makes it quite easy to get it wrong.

How and why is the approach different from those in #542 and #2564? Are there other backup programs with a similar option to follow only specific symlinks?

@cccapon
Copy link
Author

cccapon commented Aug 10, 2022

First, let me say that this patch solves my problem. For the first time, last night I completed backups of all the mounted file systems (yay!).

Initially, I thought of automatically following symbolic links only if they were top level folders of the backup.
restic backup /my/link
+- my
+- link --> /somewhere/else

but my mount points for folders often look like this:
+- client
+- abc --> /mnt/qfghtyzwflvisald
+- def --> /mnt/bhgieosllkdhfas
and, if you want to start the backup from /client the symbolic links would be skipped again.

I worried about infinite loops
+-root
+- Mine --> /root/Yours
+- Yours --> /root/Mine

and links to unrelated places (not meant to be backed up)
+-home
+- docs --> /my/giant/online/encyclopedia

so, that's where the idea of the follow pattern option came from. It would let you pick and choose which links to include.

But now, after your comment, I'm wondering if a simple --follow-all-symbolic-links option is good enough. Because you can still handle all of the above scenarios if you combine it with an --exclude pattern.
restic backup /home --follow-all-symbolic-links --exclude /home/docs

So, I have coded up another patch with just the single option for you to look at.
#3863

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

Successfully merging this pull request may close these issues.

None yet

2 participants