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

Restic backup of root of a drive letter on windows refuses to restore properly #2004

Open
addos opened this issue Sep 22, 2018 · 10 comments

Comments

@addos
Copy link

commented Sep 22, 2018

Output of restic version

restic 0.9.2 compiled with go1.10.3 on windows/amd64

How did you run restic exactly?

restic -r D:\backups backup E:
restic -r D:\backups restore -t target_dir

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

Expected behavior

It should be able to store/restore properly

Actual behavior

Restic apparently stores : in the paths, which make the repo unable to be restored?

When I run ls against my repo, it shows something like the following:
/E/E:./repo/.git/objects/info
/E/E:./repo/.git/objects/pack
/E/E:./repo/.git/refs
/E/E:./repo/.git/refs/heads
/E/E:./repo/.git/refs/heads/git-annex
/E/E:./repo/.git/refs/heads/synced
/E/E:./repo/.git/refs/heads/synced/git-annex
/E/E:./repo/.git/refs/heads/synced/master
/E/E:./repo/.git/refs/tags

When I try to restore, it shows something like the following:
ignoring error for C:\Users\brad\a\E\E:.\repo.git\objects\f6: mkdir C:\Users\brad\a\E\E:.: The filename, directory name, or volume label syntax is incorrect.
ignoring error for C:\Users\brad\a\E\E:.\repo.git\objects\f6\65cfca35e159a0a47237041d1d20edd0218ba3: mkdir C:\Users\brad\a\E\E:.: The filename, directory name, or volume label syntax is incorrect.
ignoring error for C:\Users\brad\a\E\E:.\repo.git\objects\info: mkdir C:\Users\brad\a\E\E:.: The filename, directory name, or volume label syntax is incorrect.
ignoring error for C:\Users\brad\a\E\E:.\repo.git\objects\pack: mkdir C:\Users\brad\a\E\E:.: The filename, directory name, or volume label syntax is incorrect.
ignoring error for C:\Users\brad\a\E\E:.\repo.git\refs: mkdir C:\Users\brad\a\E\E:.: The filename, directory name, or volume label syntax is incorrect.
ignoring error for C:\Users\brad\a\E\E:.\repo.git\refs\heads: mkdir C:\Users\brad\a\E\E:.: The filename, directory name, or volume label syntax is incorrect.
ignoring error for C:\Users\brad\a\E\E:.\repo.git\refs\heads\git-annex: mkdir C:\Users\brad\a\E\E:.: The filename, directory name, or volume label syntax is incorrect.
ignoring error for C:\Users\brad\a\E\E:.\repo.git\refs\heads\synced: mkdir C:\Users\brad\a\E\E:.: The filename, directory name, or volume label syntax is incorrect.
ignoring error for C:\Users\brad\a\E\E:.\repo.git\refs\heads\synced\git-annex: mkdir C:\Users\brad\a\E\E:.: The filename, directory name, or volume label syntax is incorrect.
ignoring error for C:\Users\brad\a\E\E:.\repo.git\refs\heads\synced\master: mkdir C:\Users\brad\a\E\E:.: The filename, directory name, or volume label syntax is incorrect.
ignoring error for C:\Users\brad\a\E\E:.\repo.git\refs\tags: mkdir C:\Users\brad\a\E\E:.: The filename, directory name, or volume label syntax is incorrect.
There were 371 errors

Steps to reproduce the behavior

Basically, backup the root of a drive letter on windows, and then try to restore it.

For example:
restic -r repo backup E:\

Do you have any idea what may have caused this?

I think restic is storing colons in the paths, which it can't properly restore on windows.

Do you have an idea how to solve the issue?

I think restic is storing colons in the paths, which it can't properly restore on windows.

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

All the darn time, I absolutely love this project.

@fd0 fd0 added the bug label Sep 25, 2018

@fd0

This comment has been minimized.

Copy link
Member

commented Sep 25, 2018

Uh, that's indeed a corner case we don't handle yet, I classify this as a bug. On backup, we needed a way to make saving d:\ and e:\ possible without having file names clash at the top level. This needs to somehow be undone at restore time.

Thanks for documenting this limitation!

For now, I would switch to the drive and backup relative paths, like:

E:
restic -r c:\repo backup .
@jirib

This comment has been minimized.

Copy link

commented Oct 11, 2018

I suppose this disqualifies restic to be able to restore backup of Windows C:\ drive to another drive while booted from WinPE media for disaster recovery purposes - that is, when you boot WinPE from eg. usb disk, your C:\ would be for example E:\ and you would need to restore C:\ from backup to E:.

Am I right?

@fd0

This comment has been minimized.

Copy link
Member

commented Oct 11, 2018

Am I right?

Not quite: You can do that with restic, even with this limitation. You only need to make sure that the backup is made by changing the current working directory to c:\ and calling restic like this: restic backup .. The top-level files/folders in the snapshot will then be the content of c:\, without the drive letter. You can just restore that to c:\ again, no problem.

If you run restic backup c:\ instead, that'll make restic use the drive letter as the top-level directory, so c:\boot.ini will be archived as /c:/boot.init, and restic currently has no option to strip the additional directory c: directory for restore.

@Swonkie

This comment has been minimized.

Copy link

commented Nov 10, 2018

It seems to me that, apart from the colon issue (which I didn't see), the way paths are stored does not allow to restore anything properly on Windows if an absolute path was used to make the backup. I backed up C:\Users\Swonkie and wasn't able to restore files in their original place. Restic would always create a folder structure like C:\C\Users\Swonkie\... (notice the folder called C). So basically it's a must to cd into the directory to be backed up and use ., which is very cumbersome.

@tulsti

This comment has been minimized.

Copy link

commented Nov 15, 2018

One may backup files without using a drive letter, so just use \users\swonkie and you get rid of the drive letter problem. This works just bad when having multiple drives.
It also may be a feature to strip parts of the path during restore, so making it possible not to use c: and avoid such problems.

@Swonkie

This comment has been minimized.

Copy link

commented Nov 15, 2018

I see, @tulsti
This is still inconvenient though, because I need to ensure I'm on the correct drive before using the relative path.

What is the thought behind storing the path in front of the backed up folder anyway? Wouldn't it be easiest and most flexible to just store the folder Swonkie when backing up C:\Users\Swonkie. When restoring, I could then say target: C:\Users or \Users or .

What do we gain from storing the path?

@BrianMBeaulieu

This comment has been minimized.

Copy link

commented Nov 15, 2018

I'm working on implementing restic across multiple platforms and for Windows, we need to back up D:\Folder .. so drive letter support is needed especially in server environments.

@cfbao

This comment has been minimized.

Copy link

commented Nov 15, 2018

@Swonkie Not storing the full path could be problematic when backing up multiple folders into the same repository.
For example, restic backup C:\folderA\folder1 D:\folderB\folder1, or even restic backup C:\folder D:\folder. Without full path, you can then expect a lot of collisions.

@BrianMBeaulieu

This comment has been minimized.

Copy link

commented Nov 15, 2018

Here's what happens with a UNC path.

Output from find -l:

-rw-rw-rw- 0 0 42496 2008-02-19 15:25:56 /\fs01\crystal/test/sm_dailyRouteSht_p143_cr11.rpt
-rw-rw-rw- 0 0 574464 2007-10-02 14:16:38 /\fs01\crystal/test/sm_dailyUnitBilling_p143_cr11.rpt
-rw-rw-rw- 0 0 537600 2008-03-13 15:25:22 /\fs01\crystal/test/sm_prjMntCntHrReq_p151_cr11.rpt
-rw-rw-rw- 0 0 547840 2008-03-13 15:25:20 /\fs01\crystal/test/sm_prjPartsMtlReq_p151_cr11.rpt
-rw-rw-rw- 0 0 198144 2008-02-12 14:22:44 /\fs01\crystal/test/sm_woDtlCostBill_p121_cr11.rpt
PS C:\restic>

Here's an attempted restore.. maybe I'm doing something wrong

PS C:\restic> .\run_restic.ps1 restore latest --include /\fs01\crystal/test/sm_woDtlCostBill_p121_cr11.rpt --target .
repository a490b262 opened successfully, password is correct
restoring <Snapshot 1f8fa2e0 of [\fs01\crystal] at 2018-11-15 10:18:52.6787501 -0500 EST by..> to .
ignoring error for : node has invalid name
There were 1 errors

@tulsti

This comment has been minimized.

Copy link

commented Nov 15, 2018

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