config points for disabling maintenance, email
This commit is contained in:
+15
-2
@@ -45,6 +45,12 @@ function Invoke-Unlock {
|
||||
function Invoke-Maintenance {
|
||||
Param($SuccessLog, $ErrorLog)
|
||||
|
||||
# skip maintenance if disabled
|
||||
if($SnapshotMaintenanceEnabled -eq $false) {
|
||||
Write-Output "[[Maintenance]] Skipped - maintenance disabled" | Tee-Object -Append $SuccessLog
|
||||
return
|
||||
}
|
||||
|
||||
# skip maintenance if it's been done recently
|
||||
if(($null -ne $ResticStateLastMaintenance) -and ($null -ne $ResticStateMaintenanceCounter)) {
|
||||
$Script:ResticStateMaintenanceCounter += 1
|
||||
@@ -129,6 +135,10 @@ function Invoke-Backup {
|
||||
$ShadowPath = Join-Path $item.Key 'resticVSS'
|
||||
|
||||
# Create a symbolic link to the shadow copy
|
||||
if(Test-Path $ShadowPath) {
|
||||
Write-Output "[[Backup]] VSS directory exists: '$ShadowPath' - removing. Past script failure?" | Tee-Object -Append $ErrorLog | Tee-Object -Append $SuccessLog
|
||||
cmd /c rmdir $ShadowPath
|
||||
}
|
||||
cmd /c mklink /d $ShadowPath "$device" 3>&1 2>> $ErrorLog | Tee-Object -Append $SuccessLog
|
||||
|
||||
# Build the new list of folders
|
||||
@@ -192,8 +202,10 @@ function Send-Email {
|
||||
$attachments = @{Attachments = $ErrorLog}
|
||||
$status = "ERROR"
|
||||
}
|
||||
$subject = "$env:COMPUTERNAME Restic Backup Report [$status]"
|
||||
Send-MailMessage @ResticEmailConfig -From $ResticEmailFrom -To $ResticEmailTo -Credential $credentials -Subject $subject -Body $body @attachments
|
||||
if((($status -eq "SUCCESS") -and ($SendEmailOnSuccess -ne $false)) -or (($status -eq "ERROR") -and ($SendEmailOnError -ne $false))) {
|
||||
$subject = "$env:COMPUTERNAME Restic Backup Report [$status]"
|
||||
Send-MailMessage @ResticEmailConfig -From $ResticEmailFrom -To $ResticEmailTo -Credential $credentials -Subject $subject -Body $body @attachments
|
||||
}
|
||||
}
|
||||
|
||||
function Invoke-ConnectivityCheck {
|
||||
@@ -294,6 +306,7 @@ function Invoke-Main {
|
||||
|
||||
Write-Output "Something went wrong. Sleeping for 15 min and then retrying..." | Tee-Object -Append $success_log
|
||||
if($internet_available -eq $true) {
|
||||
Invoke-HistoryCheck $success_log $error_log
|
||||
Send-Email $success_log $error_log
|
||||
}
|
||||
Start-Sleep (15*60)
|
||||
|
||||
Reference in New Issue
Block a user