From 817e67c3541c804d3ebeafd515eea3d59c6977b1 Mon Sep 17 00:00:00 2001 From: tree3887 Date: Fri, 7 May 2021 21:47:59 -0500 Subject: [PATCH 1/5] Update backup.ps1 (#36) Adds double quotes around each path and removes a trailing backslash from them as well. I have found through experimentation that restic does not like a backslash followed by a double quote. The backslash appears to be an escape character. Surrounding the path with double quotes allows paths with spaces to be used. --- backup.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backup.ps1 b/backup.ps1 index b98dc2e..e215094 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) } From e5cc051edff65b29ebb86378f9855d8fab7ef8a1 Mon Sep 17 00:00:00 2001 From: Kevin Woley Date: Fri, 7 May 2021 20:06:55 -0700 Subject: [PATCH 2/5] remove uneeded -replace parameter --- backup.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backup.ps1 b/backup.ps1 index e215094..8f8cfd4 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 = '"{0}"' -f ((Join-Path $root_path $path) -replace "\\$", "") + $p = '"{0}"' -f ((Join-Path $root_path $path) -replace "\\$") $folder_list.Add($p) } From ca90934e51c6c715af11082f176a8abb32a99c57 Mon Sep 17 00:00:00 2001 From: Kevin Woley Date: Sun, 9 May 2021 20:19:29 -0700 Subject: [PATCH 3/5] improve URL parsing, allow disabling of internet check fixes #38 --- backup.ps1 | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/backup.ps1 b/backup.ps1 index 8f8cfd4..6e8aabd 100644 --- a/backup.ps1 +++ b/backup.ps1 @@ -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)) { From 0919914dac7bd54be40c700a2f434b0a5391eeda Mon Sep 17 00:00:00 2001 From: Kevin Woley Date: Sun, 9 May 2021 20:35:06 -0700 Subject: [PATCH 4/5] internet connection test fix for PowerShell 7.1 resolves #37 --- backup.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backup.ps1 b/backup.ps1 index 6e8aabd..4243f53 100644 --- a/backup.ps1 +++ b/backup.ps1 @@ -266,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 } From 58558a6a6701dddab114760443ac8b0fa0f80bdd Mon Sep 17 00:00:00 2001 From: Kevin Woley Date: Sun, 9 May 2021 21:01:28 -0700 Subject: [PATCH 5/5] Update CHANGELOG.md 1.4.1 release notes. --- CHANGELOG.md | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) 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).