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

Timestamp is not restored correctly on file paths longer than 256 chars in Windows #1843

Open
vringel-hms opened this issue Jun 14, 2018 · 5 comments · May be fixed by #5061
Open

Timestamp is not restored correctly on file paths longer than 256 chars in Windows #1843

vringel-hms opened this issue Jun 14, 2018 · 5 comments · May be fixed by #5061
Labels

Comments

@vringel-hms
Copy link

vringel-hms commented Jun 14, 2018

Output of restic version

restic 0.9.1 compiled with go1.10.3 on windows/amd64

How did you run restic exactly?

set RESTIC_PASSWORD=<..>
set RESTIC_REPOSITORY=H:\restic_test
restic restore latest --target c:\Tools\restic\restore --include restic_backup.ps1

What backend/server/service did you use to store the repository?

Mapped Windows file share.
The file restic_backup.ps1 was backed up from a path longer than 256 chars.

Expected behavior

File will be restored with correct timestamp

Actual behavior

File was restored, but the timestamp of file is set to the restore time/date. Restic throws the following error:
ignoring error for \c\Entwicklung\12345678901234567890123456789012345678901234567890\12345678901234567890123456789012345678901234567890\12345678901234567890123456789012345678901234567890\12345678901234567890123456789012345678901234567890\12345678901234567890123456789012345678901234567890\restic_backup.ps1: RestoreTimestamps: UtimesNano: The system cannot find the path specified.

After adding the prefix "\\?\" to the path in the --target option, the restore works like expected. The timestamp of the file will be restored correctly.

Steps to reproduce the behavior

Backup a file with a pathname longer than 256 chars and try to restore it using a target directory without using the "\\?\" prefix.

Do you have any idea what may have caused this?

This problem may be a similar problem like the one described in issue #576.

Do you have an idea how to solve the issue?

If available, use a function, that supports pathnames longer than 256 chars to change the timestamp of
restored file.

Did restic help you or made you happy in any way?

Yes, indeed. Restic is an easy to use, powerful backup tool, and even if there are some small issues, it already works very good.

@mgumz
Copy link

mgumz commented Jun 23, 2018

To get an idea of why this happens and why prefixing the path with \\?\ helps: https://msdn.microsoft.com/en-us/library/windows/desktop/aa365247(v=vs.85).aspx#maxpath

@fd0
Copy link
Member

fd0 commented Jun 23, 2018

It's a bug, thanks for the report! We don't handle long paths correctly everywhere...

@fd0 fd0 added type: bug state: need implementing cause/request established, need work/solution labels Jun 23, 2018
@saviodsouza
Copy link

So what would be the full command line with "\?"

@vringel-hms
Copy link
Author

vringel-hms commented Aug 6, 2018

Using the example script from my error report, to restore the backup with correct timestamps, it would look like this:
set RESTIC_PASSWORD=<..>
set RESTIC_REPOSITORY=H:\restic_test
restic restore latest --target \\?\c:\Tools\restic\restore --include restic_backup.ps1

@MichaelEischer
Copy link
Member

This is related to #2745.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants