diff --git a/changelog/unreleased/issue-2699 b/changelog/unreleased/issue-2699 new file mode 100644 index 000000000..b933c8a52 --- /dev/null +++ b/changelog/unreleased/issue-2699 @@ -0,0 +1,9 @@ +Bugfix: Restore symbolic links on windows + +We've added support to restore symbolic links on windows. +Because of windows specific restrictions this is only possible when running +restic having SeCreateSymbolicLinkPrivilege privilege or when running as admin. + +https://github.com/restic/restic/issues/1078 +https://github.com/restic/restic/issues/2699 +https://github.com/restic/restic/pull/2875 diff --git a/doc/050_restore.rst b/doc/050_restore.rst index c7f6c0f28..cab66d54a 100644 --- a/doc/050_restore.rst +++ b/doc/050_restore.rst @@ -56,6 +56,10 @@ There are case insensitive variants of ``--exclude`` and ``--include`` called ``--iexclude`` and ``--iinclude``. These options will behave the same way but ignore the casing of paths. +Restoring symbolic links on windows is only possible when the user has +``SeCreateSymbolicLinkPrivilege`` privilege or is running as admin. This is a +restriction of windows not restic. + Restore using mount =================== diff --git a/internal/fs/file.go b/internal/fs/file.go index e8e9080d7..f35901c06 100644 --- a/internal/fs/file.go +++ b/internal/fs/file.go @@ -51,7 +51,7 @@ func Rename(oldpath, newpath string) error { // Symlink creates newname as a symbolic link to oldname. // If there is an error, it will be of type *LinkError. func Symlink(oldname, newname string) error { - return os.Symlink(fixpath(oldname), fixpath(newname)) + return os.Symlink(oldname, fixpath(newname)) } // Link creates newname as a hard link to oldname. diff --git a/internal/restic/node.go b/internal/restic/node.go index bc64b7fc3..a240384be 100644 --- a/internal/restic/node.go +++ b/internal/restic/node.go @@ -14,7 +14,6 @@ import ( "github.com/restic/restic/internal/errors" "bytes" - "runtime" "github.com/restic/restic/internal/debug" "github.com/restic/restic/internal/fs" @@ -295,10 +294,6 @@ func (node Node) writeNodeContent(ctx context.Context, repo Repository, f *os.Fi } func (node Node) createSymlinkAt(path string) error { - // Windows does not allow non-admins to create soft links. - if runtime.GOOS == "windows" { - return nil - } if err := os.Remove(path); err != nil && !errors.Is(err, os.ErrNotExist) { return errors.Wrap(err, "Symlink")