kmwoley / restic-windows-backup

Powershell scripts to run Restic backups on Windows
MIT License
330 stars 68 forks source link

Shadow Copy error when trying to backup data on a DrivePool drive #92

Open beepboop1234 opened 9 months ago

beepboop1234 commented 9 months ago

I'm getting the following error when attempting to backup data from a drive mounted with StableBit's DrivePool software (https://stablebit.com/DrivePool). DrivePool doesn't support Shadow Copy (https://community.covecube.com/index.php?/topic/4222-how-do-i-correctly-backup-stablebit-drivepool/&do=findComment&comment=28277) and I imagine this is why I'm getting the error.

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

Inside the backup.ps1 file I see this portion:

            # disable VSS / file system snapshot for external drives
            # TODO: would be best to just test for VSS compatibility on the drive, rather than assume it won't work
            $vss_option = $null

Is there something I can change here (or anywhere else) that would allow my backups to use shadow copy on the C drive and similar but not on the F drive which is the DrivePool drive?

hello-world-dot-c commented 7 months ago

I have a pseudo-fixed drive that uses a permanently installed SDcard and stumbled over the same thing. I modified the script so that it determines the drive letter for each backup source (function Get-Drives, now not only called if Test-Path fails but always) and then uses the Windows 'vssadmin' tool to get a list of drives that support VSS. If the drive from the backup source is not in the list of drives that support VSS, it disables VSS, If you're interested I can post it here or pm it. The main issue that I see why this is not a universal solution is that the 'vssadmin' tool's output will depend on the system language. My version only works in English and will need a slight change for other system languages. Of course the parse string could be added to config.ps1.

beepboop1234 commented 7 months ago

If you're interested I can post it here or pm it.

Either would be GREATLY appreciated! I imagine posting it here would make it easier for people in the future as well.

hello-world-dot-c commented 7 months ago

Here it is. Already had an idea to improve it to revert to default behaviour when vssadmin fails (e.g.wrong language). Maybe I will add this later. backup.zip

Tamnac commented 1 month ago

Weird, I'm getting this exact error, no drivepool. I only get on Powershell core (v7.4.0) though, windows powershell works fine. Been trying to figure out why that makes a difference considering powershell itself is not doing anything except passing in the argument to use vss

hello-world-dot-c commented 1 month ago

Sounds like a permission issue.

Tamnac commented 1 month ago

Sounds like a permission issue.

What permission? I'm running as admin, there's no other permissions I'm aware of

Tamnac commented 1 month ago

No, I found the issue, it seems v7.3 changed how quoted arguments are passed (see stackoverflow explanation). It can be fixed by setting

$PSNativeCommandArgumentPassing = 'Legacy'

or by removing the quoting for this line (the '"{0}"' -f part)

$p = '"{0}"' -f ((Join-Path $root_path $path) -replace "\\$")

I'll probably make a pr for it.