Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backup of files with reserved filenames fails on windows #2745

Open
MichaelEischer opened this issue May 21, 2020 · 1 comment
Open

Backup of files with reserved filenames fails on windows #2745

MichaelEischer opened this issue May 21, 2020 · 1 comment
Labels
category: backup help: wanted platform: windows state: need investigating cause unknown, need investigating/troubleshooting type: feature enhancement improving existing features

Comments

@MichaelEischer
Copy link
Member

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:

error: CreateFile \\?\\con: The parameter is incorrect.

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 yields con (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 in internal/fs/file_windows.go should only call filepath.Abs for relative paths.

@MichaelEischer MichaelEischer added category: backup platform: windows state: need investigating cause unknown, need investigating/troubleshooting type: feature enhancement improving existing features labels May 21, 2020
@greatroar
Copy link
Contributor

greatroar commented May 24, 2020

fixpath in internal/fs/file_windows.go should only call filepath.Abs for relative paths.

#2614 does that, specifically commit 052aff5.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
category: backup help: wanted platform: windows state: need investigating cause unknown, need investigating/troubleshooting type: feature enhancement improving existing features
Projects
None yet
Development

No branches or pull requests

2 participants