Merge pull request #108 from innovara/metered-check
Add feature to control backups on metered connections
This commit is contained in:
13
backup.ps1
13
backup.ps1
@@ -442,6 +442,10 @@ function Invoke-ConnectivityCheck {
|
|||||||
"[[Internet]] Waiting for connection to repository ($repository_host)... $sleep_count" | Out-File -Append $SuccessLog
|
"[[Internet]] Waiting for connection to repository ($repository_host)... $sleep_count" | Out-File -Append $SuccessLog
|
||||||
Start-Sleep 30
|
Start-Sleep 30
|
||||||
}
|
}
|
||||||
|
elseif((-not ([String]::IsNullOrEmpty($BackupOnMeteredNetwork)) -or $BackupOnMeteredNetwork)) -and Invoke-MeteredCheck)) {
|
||||||
|
"[[Internet]] Waiting for an unmetered network connection... $sleep_count" | Out-File -Append $SuccessLog
|
||||||
|
Start-Sleep 30
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
return $true
|
return $true
|
||||||
}
|
}
|
||||||
@@ -449,6 +453,15 @@ function Invoke-ConnectivityCheck {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# check if on metered network
|
||||||
|
function Invoke-MeteredCheck {
|
||||||
|
|
||||||
|
[void][Windows.Networking.Connectivity.NetworkInformation, Windows, ContentType = WindowsRuntime]
|
||||||
|
|
||||||
|
$cost = [Windows.Networking.Connectivity.NetworkInformation]::GetInternetConnectionProfile().GetConnectionCost()
|
||||||
|
$cost.ApproachingDataLimit -or $cost.OverDataLimit -or $cost.Roaming -or $cost.BackgroundDataUsageRestricted -or ($cost.NetworkCostType -ne "Unrestricted")
|
||||||
|
}
|
||||||
|
|
||||||
# check previous logs
|
# check previous logs
|
||||||
function Invoke-HistoryCheck {
|
function Invoke-HistoryCheck {
|
||||||
Param($SuccessLog, $ErrorLog, $Action)
|
Param($SuccessLog, $ErrorLog, $Action)
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ $InstallPath = "C:\restic"
|
|||||||
$ExeName = "restic.exe"
|
$ExeName = "restic.exe"
|
||||||
$GlobalParameters = @()
|
$GlobalParameters = @()
|
||||||
$LogRetentionDays = 30
|
$LogRetentionDays = 30
|
||||||
|
$BackupOnMeteredNetwork = $false
|
||||||
$InternetTestAttempts = 10
|
$InternetTestAttempts = 10
|
||||||
$GlobalRetryAttempts = 4
|
$GlobalRetryAttempts = 4
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user