updated install script to use the global parameters, removed separate $SelfUpdateParameters
This commit is contained in:
10
backup.ps1
10
backup.ps1
@@ -169,18 +169,20 @@ function Invoke-Maintenance {
|
||||
$maintenance_success = $false
|
||||
}
|
||||
|
||||
if($AllowResticSelfUpdate -eq $true) {
|
||||
# Invoke restic self-update to check for a newer version
|
||||
# This is enabled by default unless configuration disables self-update
|
||||
if ([String]::IsNullOrEmpty($SelfUpdateEnabled) -or ($SelfUpdateEnabled -eq $true)) {
|
||||
# check for updated restic version
|
||||
"[[Maintenance]] Checking for new version of restic..." | Out-File -Append $SuccessLog
|
||||
Invoke-Expression "$ResticExe $SelfUpdateParameters self-update 3>&1 2>> $ErrorLog | Out-File -Append $SuccessLog"
|
||||
Invoke-Expression "$ResticExe self-update 3>&1 2>> $ErrorLog | Out-File -Append $SuccessLog"
|
||||
if(-not $?) {
|
||||
"[[Maintenance]] Self-update of restic.exe completed with errors" | Tee-Object -Append $ErrorLog | Out-File -Append $SuccessLog
|
||||
$maintenance_success = $false
|
||||
}
|
||||
|
||||
"[[Maintenance]] End $(Get-Date)" | Out-File -Append $SuccessLog
|
||||
}
|
||||
|
||||
"[[Maintenance]] End $(Get-Date)" | Out-File -Append $SuccessLog
|
||||
|
||||
if($maintenance_success -eq $true) {
|
||||
$Script:ResticStateLastMaintenance = Get-Date
|
||||
$Script:ResticStateMaintenanceCounter = 0
|
||||
|
||||
@@ -39,5 +39,4 @@ $SnapshotMaintenanceDays = 30
|
||||
$SnapshotDeepMaintenanceDays = 90
|
||||
|
||||
# restic.exe self update configuration
|
||||
$SelfUpdateEnabled = $true
|
||||
$SelfUpdateParameters = @()
|
||||
$SelfUpdateEnabled = $true
|
||||
39
install.ps1
39
install.ps1
@@ -1,5 +1,26 @@
|
||||
. .\config.ps1
|
||||
. .\secrets.ps1
|
||||
#
|
||||
# Restic Windows Backup - Installation Script
|
||||
#
|
||||
|
||||
# =========== start configuration =========== #
|
||||
|
||||
# load restic configuration parmeters (destination, passwords, etc.)
|
||||
$SecretsScript = Join-Path $PSScriptRoot "secrets.ps1"
|
||||
|
||||
# load backup configuration variables
|
||||
$ConfigScript = Join-Path $PSScriptRoot "config.ps1"
|
||||
|
||||
# initialize secrets
|
||||
. $SecretsScript
|
||||
|
||||
# initialize config
|
||||
. $ConfigScript
|
||||
|
||||
# apply global configuration
|
||||
$global:ResticExe = Join-Path $InstallPath $ExeName
|
||||
$global:LogPath = Join-Path $InstallPath "logs"
|
||||
|
||||
# =========== end configuration =========== #
|
||||
|
||||
# download restic
|
||||
if(-not (Test-Path $ResticExe)) {
|
||||
@@ -17,15 +38,21 @@ if(-not (Test-Path $ResticExe)) {
|
||||
Get-ChildItem *.exe | Rename-Item -NewName $ExeName
|
||||
}
|
||||
|
||||
# Apply global paramters to $ResticExe, after the $ResticExe has been downloaded/confirmed to exist
|
||||
if(-not [String]::IsNullOrEmpty($GlobalParameters)) {
|
||||
$ResticExe = "$ResticExe $GlobalParameters"
|
||||
}
|
||||
|
||||
# Invoke restic self-update to check for a newer version
|
||||
if($AllowResticSelfUpdate -eq $true) {
|
||||
& $ResticExe $SelfUpdateParameters self-update
|
||||
# This is enabled by default unless configuration disables self-update
|
||||
if ([String]::IsNullOrEmpty($SelfUpdateEnabled) -or ($SelfUpdateEnabled -eq $true)) {
|
||||
Invoke-Expression "$ResticExe self-update"
|
||||
}
|
||||
|
||||
# Create log directory if it doesn't exit
|
||||
if(-not (Test-Path $LogPath)) {
|
||||
New-Item -ItemType Directory -Force -Path $LogPath | Out-Null
|
||||
Write-Output "[[Init]] Repository successfully initialized."
|
||||
Write-Output "[[Init]] Created log directory: $LogPath"
|
||||
}
|
||||
|
||||
# Create the local exclude file
|
||||
@@ -34,7 +61,7 @@ if(-not (Test-Path $LocalExcludeFile)) {
|
||||
}
|
||||
|
||||
# Initialize the restic repository
|
||||
& $ResticExe $AdditionalParameters --verbose init
|
||||
Invoke-Expression "$ResticExe --verbose init"
|
||||
if($?) {
|
||||
Write-Output "[[Init]] Repository successfully initialized."
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user