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 · 4 comments

Comments

@vringel-hms
Copy link

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

This comment has been minimized.

Copy link

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

This comment has been minimized.

Copy link
Member

commented Jun 23, 2018

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

@fd0 fd0 added bug confirmed labels Jun 23, 2018

@saviodsouza

This comment has been minimized.

Copy link

commented Aug 4, 2018

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

@vringel-hms

This comment has been minimized.

Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants
You can’t perform that action at this time.