Backup of files with reserved filenames fails on windows #2745
Labels
category: backup
help: wanted
platform: windows
state: need investigating
cause unknown, need investigating/troubleshooting
type: feature enhancement
improving existing features
based on: https://forum.restic.net/t/scan-and-error-createfile-con-the-parameter-is-incorrect/2710
Output of
restic version
restic (version 0.9.6) on Windows 10
How did you run restic exactly?
restic -r D:/ --verbose backup C:/Users/myusername/work
Output:
What backend/server/service did you use to store the repository?
Not relevant
Expected behavior
restic reports the correct filename of the problematic file and/or properly backups the file.
Actual behavior
Unintelligible error message and the file is not contained in the backup.
Steps to reproduce the behavior
This turned out to be cause by some files named
con.m
.Do you have any idea what may have caused this?
CON
is a reserved filename on windows. This rule still applies when adding a file extension like.m
.When restic tries to normalize e.g.
C:/Users/myusername/work\con.m
then the computation of the absolute path yieldscon
(I'm looking at you GetFullPathName). As restic supports paths longer than 256 characters it has to prepend\\?\
which gives us\\?\con
. (btw, the correct and non-ambiguous filename for the console device would be\\.\con
) I'm not sure where one of the backslashes disappeared in the error message.Do you have an idea how to solve the issue?
The Definitive Guide on Win32 to NT Path Conversion shows that prepending
\\?\
to an already absolute path seems to get rid of most weird behavior during filepath normalization. I'm just not sure whether the Go functions to process filenames can handle this.restic should probably convert relative paths to absolute ones as early as possible and then always add
\\?\
before passing the path to the windows API.fixpath
ininternal/fs/file_windows.go
should only callfilepath.Abs
for relative paths.The text was updated successfully, but these errors were encountered: