Add follow options for symbolic links
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 https://github.com/restic/restic/issues/3594
Checklist
- [x] I have read the contribution guidelines.
- [x] 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
gofmton 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.
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?
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