@@ -140,7 +140,7 @@ function Invoke-Backup {
140140 # Build the new list of folders from settings (if there are any)
141141 $folder_list = New-Object System.Collections.Generic.List[System.Object ]
142142 ForEach ($path in $item.Value ) {
143- $p = Join-Path $root_path $path
143+ $p = ' "{0}" ' -f (( Join-Path $root_path $path ) -replace " \\$ " )
144144 $folder_list.Add ($p )
145145 }
146146
@@ -209,9 +209,15 @@ function Send-Email {
209209
210210function Invoke-ConnectivityCheck {
211211 Param ($SuccessLog , $ErrorLog )
212+
213+ if ($InternetTestAttempts -le 0 ) {
214+ Write-Output " [[Internet]] Internet connectivity check disabled. Skipping." | Tee-Object - Append $SuccessLog
215+ return $true
216+ }
217+
212218 # skip the internet connectivity check for local repos
213219 if (Test-Path $env: RESTIC_REPOSITORY ) {
214- Write-Output " [[Internet]] Skipping internet connectivity check." | Tee-Object - Append $SuccessLog
220+ Write-Output " [[Internet]] Local repository. Skipping internet connectivity check." | Tee-Object - Append $SuccessLog
215221 return $true
216222 }
217223
@@ -233,9 +239,13 @@ function Invoke-ConnectivityCheck {
233239 }
234240 else {
235241 # parse connection string for hostname
236- # Uri parser doesn't handle leading connection type info (s3:, sftp:, rest:)
242+ # Uri parser doesn't handle leading connection type info (s3:, sftp:, rest:)
237243 $connection_string = $env: RESTIC_REPOSITORY -replace " ^s3:" -replace " ^sftp:" -replace " ^rest:"
238- $repository_host = ([System.Uri ]$connection_string ).host
244+ if (-not ($connection_string -match " ://" )) {
245+ # Uri parser expects to have a protocol. Add 'https://' to make it parse correctly.
246+ $connection_string = " https://" + $connection_string
247+ }
248+ $repository_host = ([System.Uri ]$connection_string ).DnsSafeHost
239249 }
240250
241251 if ([string ]::IsNullOrEmpty($repository_host )) {
@@ -256,7 +266,7 @@ function Invoke-ConnectivityCheck {
256266 Write-Output " [[Internet]] Waiting for internet connectivity... $sleep_count " | Tee-Object - Append $SuccessLog
257267 Start-Sleep 30
258268 }
259- elseif (! (Test-Connection - Server $repository_host - Quiet)) {
269+ elseif (! (Test-Connection - ComputerName $repository_host - Quiet)) {
260270 Write-Output " [[Internet]] Waiting for connection to repository ($repository_host )... $sleep_count " | Tee-Object - Append $SuccessLog
261271 Start-Sleep 30
262272 }
0 commit comments