issue2699: restore symlinks on windows when run as admin user#2875
issue2699: restore symlinks on windows when run as admin user#2875MichaelEischer merged 4 commits intorestic:masterfrom
Conversation
|
Instead of checking for the Admin User it would be more general to check whether the user has the SeCreateSymbolicLinkPrivilege privilege. Additional there is the possibility to create symlinks without elevation if developer mode is activated for Windows 10 and CreateSymbolicLink is called with the SYMBOLIC_LINK_FLAG_ALLOW_UNPRIVILEGED_CREATE flag. |
|
@hgraeber Implemented in my last commit. Please have a look. |
|
In principle the check for the check for the privilege looks good to me, but I am a go newbie coming from C/C++. After thinking more about this, I have doubts whether it is worth making this check to this extent.The only thing it does is getting an error message before creating symlinks. Simply trying to create a symlink an having a error message if it fails should be sufficient. Having the privilege - eg. through an elevated command prompt - is needed in both cases. So dropping in |
|
@hgraeber A valid option. I'd add some windows specific code to the error handling to give the user a more specific source of the problem inside the error handling block after calling fs.Symlink(). I'm going to wait for some official feedback on how to continue before putting more work into this PR. |
werbes
left a comment
There was a problem hiding this comment.
I have done several restore jobs with this new code on Windows and it gets the symbolic links right when restoring now.
|
Please, implement this. It's been 2 years |
It's pretty clear restic is just unsupported/abandonware on Windows. It's had data loss inducing bugs with both backup and restore containing symlinks/junctions being broken since release, and unmerged fixes sitting for years. |
Windows support for restic has always been primarily community driven, AFAIK there's not much/no windows usage among the maintainers. Nevertheless, I try to also fix Windows-specific problems from time to time. But some pull requests get buried under the large pile of other PRs and then it takes quite some time to dig them out again. Would you care to elaborate which specific bugs you are referring to? |
|
I will look into this in a few days. @MichaelEischer What about os.Symlink()? Will this be fixed or should this PR keep the workaround for now? |
Please change and remove the workaround afterwards. |
|
@fgma Any progress with cleaning up the PR? |
|
@MichaelEischer Looking into it right now. |
527ce36 to
17e67b3
Compare
17e67b3 to
8e5eb10
Compare
|
I've rebased and squashed the PR to remove the duplicate commits. The changelog now also contains links to all fixed issues and this PR. |
5144a59 to
8fe159c
Compare
What does this PR change? What problem does it solve?
Currently symlinks on windows are backed up but not restored. Because of windows restrictions this is only possible with admin privileges. This patch checks if the user running restic has sufficient privileges to restore symlinks and restores them if possible.
For testing the feature you may use the attached demo script: issue2699.zip
Running demo.bat will do the following:
Was the change discussed in an issue or in the forum before?
Closes #2699
Closes #1078
Checklist
changelog/unreleased/that describes the changes for our users (template here)gofmton the code in all commits