From 63a8bb9218d897b43f5efeb9ef6931a0ad84d32d Mon Sep 17 00:00:00 2001 From: Kevin Woley Date: Thu, 30 Apr 2020 09:49:49 -0700 Subject: [PATCH] retry error messaging improvements --- backup.ps1 | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/backup.ps1 b/backup.ps1 index 5f86393..afc1d2f 100644 --- a/backup.ps1 +++ b/backup.ps1 @@ -322,13 +322,20 @@ function Invoke-Main { Write-Warning "Errors found! Error Log: $error_log" $error_count++ - Write-Output "Something went wrong. Sleeping for 15 min and then retrying..." | Tee-Object -Append $success_log + $attempt_count-- + if($attempt_count -gt 0) { + Write-Output "Sleeping for 15 min and then retrying..." | Tee-Object -Append $success_log + } + else { + Write-Output "Retry limit has been reached. No more attempts to backup will be made." | 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) - $attempt_count-- + if($attempt_count -gt 0) { + Start-Sleep (15*60) + } } Set-BackupState