From b73008a5f1310f908e433261be8fcb43dfc8b60e Mon Sep 17 00:00:00 2001 From: Kevin Woley Date: Tue, 28 Apr 2020 20:08:41 -0700 Subject: [PATCH 1/3] internet connectivity check handles all repo types Closes #10 --- backup.ps1 | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/backup.ps1 b/backup.ps1 index 8dd1c91..dcc85d3 100644 --- a/backup.ps1 +++ b/backup.ps1 @@ -212,20 +212,29 @@ function Send-Email { function Invoke-ConnectivityCheck { Param($SuccessLog, $ErrorLog) - + # Skip the internet connectivity check unsupported repo types (i.e. swift:, rclone:, or local ) + if(($env:RESTIC_REPOSITORY -match "^swift:") -or ($env:RESTIC_REPOSITORY -match "^rclone:") -or (Test-Path $env:RESTIC_REPOSITORY)) { + Write-Output "[[Internet]] Skipping internet connectivity check." | Tee-Object -Append $SuccessLog + return $true + } + # parse connection string for hostname - # TODO: handle non-s3 repositories - # Uri parser doesn't handle leading connection type info - $connection_string = $env:RESTIC_REPOSITORY -replace "s3:" + # Uri parser doesn't handle leading connection type info (s3:, sftp:, rest:, azure:, gs:) + $connection_string = $env:RESTIC_REPOSITORY -replace "^s3:" -replace "^sftp:" -replace "^rest:" -replace "^azure:" -replace "^gs:" $repository_host = ([System.Uri]$connection_string).host + if([string]::IsNullOrEmpty($repository_host)) { + Write-Output "[[Internet]] Repository string could not be parsed." | Tee-Object -Append $SuccessLog | Tee-Object -Append $ErrorLog + return $false + } + # test for internet connectivity $connections = 0 $sleep_count = $InternetTestAttempts while($true) { $connections = Get-NetRoute | Where-Object DestinationPrefix -eq '0.0.0.0/0' | Get-NetIPInterface | Where-Object ConnectionState -eq 'Connected' | Measure-Object | ForEach-Object{$_.Count} if($sleep_count -le 0) { - Write-Output "[[Internet]] Connection to repository could not be established." | Tee-Object -Append $SuccessLog | Tee-Object -Append $ErrorLog + Write-Output "[[Internet]] Connection to repository ($repository_host) could not be established." | Tee-Object -Append $SuccessLog | Tee-Object -Append $ErrorLog return $false } if(($null -eq $connections) -or ($connections -eq 0)) { From 5ef9e3bb53b78de3176785ce6ded21f1df2c6581 Mon Sep 17 00:00:00 2001 From: Kevin Woley Date: Tue, 28 Apr 2020 20:28:08 -0700 Subject: [PATCH 2/3] add 32-bit windows support to the install Closes #7 --- install.ps1 | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/install.ps1 b/install.ps1 index 53ddff4..aa8df60 100644 --- a/install.ps1 +++ b/install.ps1 @@ -3,7 +3,13 @@ # download restic if(-not (Test-Path $ResticExe)) { - $url = "https://github.com/restic/restic/releases/download/v0.9.6/restic_0.9.6_windows_amd64.zip" + $url = $null + if([Environment]::Is64BitOperatingSystem){ + $url = "https://github.com/restic/restic/releases/download/v0.9.6/restic_0.9.6_windows_amd64.zip" + } + else { + $url = "https://github.com/restic/restic/releases/download/v0.9.6/restic_0.9.6_windows_386.zip" + } $output = Join-Path $InstallPath "restic.zip" Invoke-WebRequest -Uri $url -OutFile $output Expand-Archive -LiteralPath $output $InstallPath From 6edfe75696ce4fccf2d8089c1054ebc5fcd38658 Mon Sep 17 00:00:00 2001 From: Kevin Woley Date: Tue, 28 Apr 2020 20:41:08 -0700 Subject: [PATCH 3/3] Changelog update. --- CHANGELOG.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 49fdede..bf44f61 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,19 @@ # Changelog +## [1.2](https://github.com/kmwoley/restic-windows-backup/tree/HEAD) + +[Full Changelog](https://github.com/kmwoley/restic-windows-backup/compare/1.1...HEAD) + +* Internet connectivity test now supports more repository types (s3:, sftp:, rest:, azure:, gs:), and ignores unsupported (swift:, rclone: and local) +* Add 32-bit support in the `install.ps1` + + +**Closed issues:** + +- Use non-s3 repos [\#10](https://github.com/kmwoley/restic-windows-backup/issues/10) +- Test-Connection fails [\#9](https://github.com/kmwoley/restic-windows-backup/issues/9) +- Add changelog [\#1](https://github.com/kmwoley/restic-windows-backup/issues/1) + ## [1.1](https://github.com/kmwoley/restic-windows-backup/tree/1.1) (2020-02-15) [Full Changelog](https://github.com/kmwoley/restic-windows-backup/compare/1.0...1.1) @@ -21,6 +35,7 @@ $SendEmailOnError = $true **Merged pull requests:** +- add changelog [\#6](https://github.com/kmwoley/restic-windows-backup/pull/6) ([kmwoley](https://github.com/kmwoley)) - add options to enable/disable email sending and maintenance [\#4](https://github.com/kmwoley/restic-windows-backup/pull/4) ([kmwoley](https://github.com/kmwoley)) ## [1.0](https://github.com/kmwoley/restic-windows-backup/tree/1.0) (2020-02-09)