backrest
backrest copied to clipboard
Restore path on Windows is wrong
Describe the bug Restore path on Windows is wrong, it kinda duplicates it.
Example:
I need to restore C:\Users\John\Desktop\Photos
I select the folder, then I choose the such path. The restore happens is such folder, but in the folder "Photos" it has re-created all the structure from the root. There's a C folder, then a Users folder and so on.
To Reproduce Steps to reproduce the behavior:
- Pick a folder to be restored
- Enter the correct path of the folder
- Observe that inside the destination folder the path is createt from the root.
Expected behavior Restore the files as they are
Platform Info
- Windows 10 22H2 x64
- Backrest Version; 1.6.1
This does need fixing -- a targeted patch related to this was done for Linux, I need to implement and test something similar for Windows.
Relevant lines of code are https://github.com/garethgeorge/backrest/blob/b7abbf9603196e1ed169ebbe81d97d5fa89dea08/internal/orchestrator/repo/repo.go#L309-L320 , which as you can see involve a bit of command crafting. Some work is needed to figure out whether the same or something similar works well on windows.
To add to this, mine just "fails"
The first restore I've tried to do seemingly failed with an "access denied" even though I was restoring some Desktop items into some Desktop subfolder. But then I see it's actually restored to C:\Users\username.
Finally I override the path which was /c/users/etc... to C:\Users\username\Desktop and this time it does work though it's still reported as having failed. The target seems wrong and more for Linux systems
[repo-manager] 08:53:24.680Z debug restore snapshot {"repo": "Local", "snapshot": "375487f9644e65c17be477a196dbfbfb67f71855347c9253385f56bdcb2c868f", "target": "C:\\Users\\QuarkZ\\Desktop\\Desktop-backrest-restore-375487f9"}
[restic] command: C:\Program Files\Backrest\restic.exe restore --json 375487f9644e65c17be477a196dbfbfb67f71855347c9253385f56bdcb2c868f -o sftp.args=-oBatchMode=yes --target C:\Users\QuarkZ\Desktop\Desktop-backrest-restore-375487f9 --include /c/users/QuarkZ/Desktop
[restic] {"message_type":"error","error":{"message":"UtimesNano: Access is denied."},"during":"restore","item":"\\c\\users"}
This error looks related to https://github.com/restic/restic/issues/5133 .
backrest does run restore tests on windows as a part of the release process, not immediately apparent why you’d specifically be seeing this error with your backups .
Re: the restore path and target I don’t immediately see what’s wrong there, but windows path handling has had a number of errors in the past— it’s possible something is broken here. Can you add a bit more explicit information — what exact path in the repo did you expect to restore, what was the expected target, and what logs did you get?
Well, for example, trying to restore a single file that was on the Desktop automatically does this:
It gives a failure error
[repo-manager] 13:29:09.700Z debug restore snapshot {"repo": "Online", "snapshot": "f696ab05c849110a2b50d5854c23610ac0801e310a1952974745cfbe9022b964", "target": "/C/Users/QuarkZ/Desktop/v2.ahk-backrest-restore-f696ab05"}
[restic]
[restic] command: C:\Program Files\Backrest\restic.exe restore --json f696ab05c849110a2b50d5854c23610ac0801e310a1952974745cfbe9022b964 -o sftp.args=-oBatchMode=yes --target /C/Users/QuarkZ/Desktop/v2.ahk-backrest-restore-f696ab05 --include /C/Users/QuarkZ/Desktop/v2.ahk
[restic] {"message_type":"error","error":{"message":"UtimesNano: Access is denied."},"during":"restore","item":"\\C\\Users"}
[restic] {"message_type":"summary","total_files":1,"files_restored":4,"total_bytes":261,"bytes_restored":261}
[restic] Fatal: There were 1 errors
[restic]
[tasklog] 13:29:12.354Z error restore snapshot "f696ab05c849110a2b50d5854c23610ac0801e310a1952974745cfbe9022b964" in repo "Online" task failed {"error": "restore failed: restore snapshot \"f696ab05c849110a2b50d5854c23610ac0801e310a1952974745cfbe9022b964\" for repo Online: command \"C:\\\\Program Files\\\\Backrest\\\\restic.exe restore --json f696ab05c849110a2b50d5854c23610ac0801e310a195297...\" failed: exit code 1: restore failed", "duration": 2.6536478}
but in fact the file was restored to:
C:\C\Users\QuarkZ\Desktop\v2.ahk-backrest-restore-f696ab05\C\Users\QuarkZ\Desktop
If I override the path given
It gives basically the same error but this time restores to:
C:\Users\QuarkZ\Desktop\v2.ahk-backrest-restore-f696ab05\C\Users\QuarkZ\Desktop
If I leave the path blank, it tries to restore into a subfolder where the backrest exe resides, but also fails, this time completely, with the same permission error.
Alright, so I ran backrest explicitly as admin and the error went away, but the result is the same, using the path /c/etc creates the folder structure as above, and using c:\etc instead, creates the folder structure on the Desktop, but in both case doesn't restore just the file.
I'm thinking it must be because of how the include is structured though. The doc shows:
which then seems to indicate the proper command would be:
restore snapshot:/c/full_path_to_folder_containing_file --target C:\users\user\desktop --include /file.jpg