issue2699: restore symlinks on windows when run as admin user

This commit is contained in:
fgma 2020-08-05 20:16:37 +02:00 committed by Michael Eischer
parent f8910bc4ff
commit 8e5eb1090c
4 changed files with 14 additions and 6 deletions

View File

@ -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

View File

@ -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 ``--iexclude`` and ``--iinclude``. These options will behave the same way but
ignore the casing of paths. 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 Restore using mount
=================== ===================

View File

@ -51,7 +51,7 @@ func Rename(oldpath, newpath string) error {
// Symlink creates newname as a symbolic link to oldname. // Symlink creates newname as a symbolic link to oldname.
// If there is an error, it will be of type *LinkError. // If there is an error, it will be of type *LinkError.
func Symlink(oldname, newname string) error { 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. // Link creates newname as a hard link to oldname.

View File

@ -14,7 +14,6 @@ import (
"github.com/restic/restic/internal/errors" "github.com/restic/restic/internal/errors"
"bytes" "bytes"
"runtime"
"github.com/restic/restic/internal/debug" "github.com/restic/restic/internal/debug"
"github.com/restic/restic/internal/fs" "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 { 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) { if err := os.Remove(path); err != nil && !errors.Is(err, os.ErrNotExist) {
return errors.Wrap(err, "Symlink") return errors.Wrap(err, "Symlink")