Merge pull request #13 from kmwoley/option-refinement

1.2 Release
This commit is contained in:
Kevin Woley
2020-04-28 20:42:49 -07:00
committed by GitHub
3 changed files with 36 additions and 6 deletions

View File

@@ -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)

View File

@@ -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)) {

View File

@@ -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