diff --git a/CHANGELOG.md b/CHANGELOG.md index 018d269..988ef47 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,19 @@ # Changelog +## [1.4.1](https://github.com/kmwoley/restic-windows-backup/tree/1.4.1) (2021-05-29) +[Full Changelog](https://github.com/kmwoley/restic-windows-backup/compare/1.4...1.4.1) + +Bugfix release. + +## Fixes +- Improved URL parsing so that the internet connectivity check works if the URL doesn't provide a protocol +- Add PowerShell 7.1 support to internet connectivity check + +## Enhancements +- Setting $InternetTestAttempts to 0 will now bypass the internet connectivity checks entirely + ## [1.4](https://github.com/kmwoley/restic-windows-backup/tree/1.4) (2021-02-24) -[Full Changelog](https://github.com/kmwoley/restic-windows-backup/compare/1.3...HEAD) +[Full Changelog](https://github.com/kmwoley/restic-windows-backup/compare/1.3...1.4) Moved to using Restic's inbuilt filesystem shadow copy creation (VSS). diff --git a/backup.ps1 b/backup.ps1 index b98dc2e..4243f53 100644 --- a/backup.ps1 +++ b/backup.ps1 @@ -140,7 +140,7 @@ function Invoke-Backup { # Build the new list of folders from settings (if there are any) $folder_list = New-Object System.Collections.Generic.List[System.Object] ForEach ($path in $item.Value) { - $p = Join-Path $root_path $path + $p = '"{0}"' -f ((Join-Path $root_path $path) -replace "\\$") $folder_list.Add($p) } @@ -209,9 +209,15 @@ function Send-Email { function Invoke-ConnectivityCheck { Param($SuccessLog, $ErrorLog) + + if($InternetTestAttempts -le 0) { + Write-Output "[[Internet]] Internet connectivity check disabled. Skipping." | Tee-Object -Append $SuccessLog + return $true + } + # skip the internet connectivity check for local repos if(Test-Path $env:RESTIC_REPOSITORY) { - Write-Output "[[Internet]] Skipping internet connectivity check." | Tee-Object -Append $SuccessLog + Write-Output "[[Internet]] Local repository. Skipping internet connectivity check." | Tee-Object -Append $SuccessLog return $true } @@ -233,9 +239,13 @@ function Invoke-ConnectivityCheck { } else { # parse connection string for hostname - # Uri parser doesn't handle leading connection type info (s3:, sftp:, rest:) + # Uri parser doesn't handle leading connection type info (s3:, sftp:, rest:) $connection_string = $env:RESTIC_REPOSITORY -replace "^s3:" -replace "^sftp:" -replace "^rest:" - $repository_host = ([System.Uri]$connection_string).host + if(-not ($connection_string -match "://")) { + # Uri parser expects to have a protocol. Add 'https://' to make it parse correctly. + $connection_string = "https://" + $connection_string + } + $repository_host = ([System.Uri]$connection_string).DnsSafeHost } if([string]::IsNullOrEmpty($repository_host)) { @@ -256,7 +266,7 @@ function Invoke-ConnectivityCheck { Write-Output "[[Internet]] Waiting for internet connectivity... $sleep_count" | Tee-Object -Append $SuccessLog Start-Sleep 30 } - elseif(!(Test-Connection -Server $repository_host -Quiet)) { + elseif(!(Test-Connection -ComputerName $repository_host -Quiet)) { Write-Output "[[Internet]] Waiting for connection to repository ($repository_host)... $sleep_count" | Tee-Object -Append $SuccessLog Start-Sleep 30 }