Backing up a disk image, not files, under Windows using VSS

I’m trying to figure out how to back up an entire disk image under Windows. Using other means, I’ve created a VSS snapshot. I’d like to issue a command like:

restic backup [...] "\\?\GLOBALROOT\Device\HarddiskVolumeShadowCopy22"

When I do that, restic seems to work but then fails with:

Fatal: unable to save snapshot: CreateFile \\?\GLOBALROOT\: The filename, directory name, or volume label syntax is incorrect.

Any ideas as to how I can get this to work?

1 Like

restic supports VSS out of the box --use-fs-snapshot. No need to use other means.

https://restic.readthedocs.io/en/stable/040_backup.html?highlight=VSS#backing-up

1 Like

I understand that, and I use it that way. I also want the ability to back up a raw disk image from VSS rather than its contents. Surely there’s some way to output that VSS snapshot as bytes that I can pipe to restic as stdin?

restic can get stdin as an input - so it is not restic problem but some windows voodoo needed:)

If you find a way to save your VSS image to a file than you are at home I think

You could always use Disk2VHD and then use restic to throw that off somewhere. It should be farily straight forward to script.

Keep in mind that there’s no way to restore any such raw data back to the disk, using restic. The built-in command wbadmin can backup entire volumes with VSS, but doesn’t support outputting to stdout.

Yeah, I could easily use Linux tools to dump an image back out onto a disk or mount it virtually to copy files. The idea would just be to have incremental backups (using restic’s sliding window for deduplication) of physical NTFS volumes. But, as usual, the problem is that nothing (that I know of) can output to stdout.

1 Like

When using absolute paths, restic always includes the folder between the filesystem root and the selected file in a snapshot. Using regular paths that works well, but not in this case.

Creating a symlink to the \\?\GLOBALROOT\Device\ folder might work, along with telling restic to backup up that file through the symlinked folder.

That was a great idea, but unfortunately restic throws an error:

error: readlink \\?\C:\SHADOW: Incorrect function

Any other ideas?

try cd C:\SHADOW followed by restic backup .. When creating a backup from a relative path, restic doesn’t look at the parent folders.

Ah, but I want to back up the raw disk image rather than directories - I know I can do the latter already with --use-fs-snapshot and it works perfectly. The goal here is to get the Windows equivalent of the Linux dd if=/dev/mapper/root-snapshot of=/dev/stdout | restic backup --stdin... and that should be possible since shadow copies present the entire volume as e.g. \\?\GLOBALROOT\Device\HarddiskVolumeShadowCopy22.

doesn’t cd C:\SHADOW and restic backup .\HarddiskVolumeShadowCopy22 workm assuming that C:\SHADOW points to \\?\GLOBALROOT\Device?

If I remember correctly, then CMD.exe should be able to redirect files (not sure about disk images though), could that work?

I didn’t try linking to \\?\GLOBALROOT\Device. I’ll give that a shot and post results.

Nope. \\?\GLOBALROOT\Device can’t be listed or traversed or properly linked to. I can create a symlink to my specific shadow copy, but then it’s a normal directory tree and what restic does under the hood.

Hmm, then I’m out of ideas. I’m wondering though whether there is some PowerShell function which would work…

I want to back up the raw disk image rather than directories

I’m not sure this is actually possible only using VSS. As far as I can see, the VSS snapshot behaves like a disk drive in terms of access; it’s not a regular file. So it’s similar to a btrfs or zfs snapshot in linux.
You noted for linux you’d need to use dd to read the disk contents before passing the data to restic via stdout, and based on some cursory research, this holds true for windows also.

I think you’ll need to insert some sort of disk imaging software into the chain here, replacing dd in your linux equivalent example. Disk2VHD was already suggested (although there would be apparently be some challenges restoring the image to a disk), and there are plenty of other windows disk imaging solutions out there.
The only difference from the linux example is that you would need to write the output file from the imaging software somewhere first, as google suggests windows doesn’t have an equivalent of /dev/stdout unfortunately.

Also, it could be worth backing up a sec, looking at the big picture, and asking; what exactly are you hoping to accomplish by backing up the VSS snapshot itself?

If I’ve understood it correctly, a VSS snapshot does not contain information on disk geometry, or indeed anything apart from the contents of the filesystem, as each snapshot is specific to a single volume (filesystem).
If so, your backup of the VSS snapshot doesn’t sound like it would include any additional information when compared to a regular backup of the filesystems’ contents?

I’m not trying to be difficult by asking the above, but if you share your end goal (i.e. why you want the VSS snapshot to be sent to restic as a stream of raw data), maybe one of the forum members can see an alternative path to that end goal that is less headache-inducing for you :slight_smile: