removed snapshot code, added --use-fs-snapshot
Related changes - removed folder enumeration and instead point to the root filesystem: snapshot handling will be better now that changing folders won't group sets default exlusion list updates: C:\$Recycle.Bin C:\$WINDOWS.~BT C:\$WinREAgent
This commit is contained in:
+12
-34
@@ -127,29 +127,17 @@ function Invoke-Backup {
|
|||||||
$starting_location = Get-Location
|
$starting_location = Get-Location
|
||||||
ForEach ($item in $BackupSources.GetEnumerator()) {
|
ForEach ($item in $BackupSources.GetEnumerator()) {
|
||||||
|
|
||||||
$ShadowPath = Join-Path $item.Key 'resticVSS'
|
# Get the source drive letter and set as the root path
|
||||||
|
$root_path = $item.Key
|
||||||
|
|
||||||
# check for existance of previous, orphaned VSS directory (and remove it) before creating the shadow copy
|
# Avoid storing the drive letter in the backup path if only backing up a single drive
|
||||||
if(Test-Path $ShadowPath) {
|
# FIXME: this doesn't really work. "C:\" still gets stored
|
||||||
Write-Output "[[Backup]] VSS directory exists: '$ShadowPath' - removing. Past script failure?" | Tee-Object -Append $ErrorLog | Tee-Object -Append $SuccessLog
|
|
||||||
cmd /c rmdir $ShadowPath
|
|
||||||
}
|
|
||||||
|
|
||||||
# Create the shadow copy
|
|
||||||
$s1 = (Get-WmiObject -List Win32_ShadowCopy).Create($item.Key, "ClientAccessible")
|
|
||||||
$s2 = Get-WmiObject -Class Win32_ShadowCopy | Where-Object { $_.ID -eq $s1.ShadowID }
|
|
||||||
|
|
||||||
# Create a symbolic link to the shadow copy
|
|
||||||
$device = $s2.DeviceObject + "\"
|
|
||||||
cmd /c mklink /d $ShadowPath "$device" 3>&1 2>> $ErrorLog | Tee-Object -Append $SuccessLog
|
|
||||||
|
|
||||||
# Build the new list of folders
|
|
||||||
$root_path = $ShadowPath
|
|
||||||
if($drive_count -eq 1) {
|
if($drive_count -eq 1) {
|
||||||
|
Set-Location $root_path
|
||||||
$root_path = "."
|
$root_path = "."
|
||||||
Set-Location $ShadowPath
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Build the new list of folders from settings (if there are any)
|
||||||
$folder_list = New-Object System.Collections.Generic.List[System.Object]
|
$folder_list = New-Object System.Collections.Generic.List[System.Object]
|
||||||
ForEach ($path in $item.Value) {
|
ForEach ($path in $item.Value) {
|
||||||
$p = Join-Path $root_path $path
|
$p = Join-Path $root_path $path
|
||||||
@@ -157,30 +145,20 @@ function Invoke-Backup {
|
|||||||
}
|
}
|
||||||
|
|
||||||
# backup everything in the root if no folders are provided
|
# backup everything in the root if no folders are provided
|
||||||
# note this won't select items with hidden attributes (a good thing to avoid)
|
|
||||||
if (-not $folder_list) {
|
if (-not $folder_list) {
|
||||||
ForEach ($path in Get-ChildItem $ShadowPath) {
|
$folder_list.Add($root_path)
|
||||||
$p = Join-Path $root_path $path
|
|
||||||
$folder_list.Add($p)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# Launch Restic
|
# Launch Restic
|
||||||
& $ResticExe backup $folder_list --exclude-file=$WindowsExcludeFile --exclude-file=$LocalExcludeFile 3>&1 2>> $ErrorLog | Tee-Object -Append $SuccessLog
|
& $ResticExe backup $folder_list --use-fs-snapshot --exclude-file=$WindowsExcludeFile --exclude-file=$LocalExcludeFile 3>&1 2>> $ErrorLog | Tee-Object -Append $SuccessLog
|
||||||
if(-not $?) {
|
if(-not $?) {
|
||||||
Write-Output "[[Backup]] Completed with errors" | Tee-Object -Append $ErrorLog | Tee-Object -Append $SuccessLog
|
Write-Output "[[Backup]] Completed with errors" | Tee-Object -Append $ErrorLog | Tee-Object -Append $SuccessLog
|
||||||
$return_value = $false
|
$return_value = $false
|
||||||
}
|
}
|
||||||
|
|
||||||
# Delete the shadow copy and remove the symbolic link
|
|
||||||
if($drive_count -eq 1) {
|
|
||||||
Set-Location $starting_location
|
|
||||||
}
|
|
||||||
$s2.Delete()
|
|
||||||
cmd /c rmdir $ShadowPath
|
|
||||||
|
|
||||||
Write-Output "[[Backup]] End $(Get-Date)" | Tee-Object -Append $SuccessLog
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Set-Location $starting_location
|
||||||
|
Write-Output "[[Backup]] End $(Get-Date)" | Tee-Object -Append $SuccessLog
|
||||||
|
|
||||||
return $return_value
|
return $return_value
|
||||||
}
|
}
|
||||||
|
|||||||
+21
-19
@@ -1,23 +1,25 @@
|
|||||||
# default excludes
|
# default excludes
|
||||||
# examples https://github.com/duplicati/duplicati/blob/master/Duplicati/Library/Utility/FilterGroups.cs
|
# examples https://github.com/duplicati/duplicati/blob/master/Duplicati/Library/Utility/FilterGroups.cs
|
||||||
# note, because we're using a VSS directory, we can use that as the root dir for exclude rules (i.e. resticVSS)
|
C:\hiberfil.sys
|
||||||
resticVSS\hiberfil.sys
|
C:\pagefile.sys
|
||||||
resticVSS\pagefile.sys
|
C:\swapfile.sys
|
||||||
resticVSS\swapfile.sys
|
C:\$Recycle.Bin
|
||||||
resticVSS\$Recycle.Bin
|
C:\autoexec.bat
|
||||||
resticVSS\autoexec.bat
|
C:\Config.Msi
|
||||||
resticVSS\Config.Msi
|
C:\Documents and Settings
|
||||||
resticVSS\Documents and Settings
|
C:\Recycled
|
||||||
resticVSS\Recycled
|
C:\Recycler
|
||||||
resticVSS\Recycler
|
C:\$$Recycle.Bin
|
||||||
resticVSS\System Volume Information
|
C:\System Volume Information
|
||||||
resticVSS\Recovery
|
C:\Recovery
|
||||||
resticVSS\Program Files
|
C:\Program Files
|
||||||
resticVSS\Program Files (x86)
|
C:\Program Files (x86)
|
||||||
resticVSS\ProgramData
|
C:\ProgramData
|
||||||
resticVSS\PerfLogs
|
C:\PerfLogs
|
||||||
resticVSS\Windows
|
C:\Windows
|
||||||
resticVSS\Windows.old
|
C:\Windows.old
|
||||||
|
C:\$$WINDOWS.~BT
|
||||||
|
C:\$$WinREAgent
|
||||||
Microsoft\Windows\Recent
|
Microsoft\Windows\Recent
|
||||||
Microsoft\**\RecoveryStore*
|
Microsoft\**\RecoveryStore*
|
||||||
Microsoft\**\Windows\*.edb
|
Microsoft\**\Windows\*.edb
|
||||||
@@ -32,7 +34,7 @@ UsrClass.dat
|
|||||||
Dropbox
|
Dropbox
|
||||||
AppData\Local\Google\Drive
|
AppData\Local\Google\Drive
|
||||||
Google Drive\.tmp.drivedownload
|
Google Drive\.tmp.drivedownload
|
||||||
resticVSS\OneDriveTemp
|
C:\OneDriveTemp
|
||||||
|
|
||||||
# browsers
|
# browsers
|
||||||
Google\Chrome
|
Google\Chrome
|
||||||
|
|||||||
Reference in New Issue
Block a user