Daily Weekly Monthly

Daily Shaarli

All links of one day in a single page.

May 7, 2018

Add support for VSS (windows) · Issue #340 · restic/restic · GitHub

To more easily integrate restic with automatic VSS creation I wrote a Windows PowerShell script that can be run to automate this without the complications mentioned above. It is available in the attached zip:
restic-backup-windows-vss.zip

If restic has a repository for external scripts but perhaps it could be included there.

The meat of the script is in these lines excerpted from the script (omitting the config part):

$ShadowPath = $rootVolume + 'shadowcopy\'

Create a volume shadow copy and make it accessible

$s1 = (Get-WmiObject -List Win32_ShadowCopy).Create($rootVolume, "ClientAccessible")
$s2 = Get-WmiObject Win32ShadowCopy | Where-Object { $.ID -eq $s1.ShadowID }
$device = $s2.DeviceObject + "\"

Create a symbolic link to the shadow copy

cmd /c mklink /d $ShadowPath "$device"

Run Restic on the data files in the shadowcopy

ForEach ($folderToBackup in $foldersToBackup) {
cmd /c $resticExe backup -r $resticRepository ($ShadowPath + $folderToBackup)
}

Delete the shadow copy and remove the symbolic link

$s2.Delete()
cmd /c rmdir $ShadowPath