add custom actions configuration to enable invoking scripts other commands on script start and end. Defined by $CustomAction* config variables.
This commit is contained in:
19
backup.ps1
19
backup.ps1
@@ -546,6 +546,11 @@ function Invoke-Main {
|
|||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# custom start action
|
||||||
|
if($null -ne $CustomActionStart) {
|
||||||
|
Invoke-Expression $CustomActionStart
|
||||||
|
}
|
||||||
|
|
||||||
$error_count = 0
|
$error_count = 0
|
||||||
$backup_success = $false
|
$backup_success = $false
|
||||||
$maintenance_success = $false
|
$maintenance_success = $false
|
||||||
@@ -671,6 +676,20 @@ function Invoke-Main {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# custom end actions
|
||||||
|
if((-not $backup_success) -or ($maintenance_needed -and -not $maintenance_success)) {
|
||||||
|
# call the custom error action if backup failed and/or maintenance was needed and failed
|
||||||
|
if($null -ne $CustomActionEndError) {
|
||||||
|
Invoke-Expression $CustomActionEndError
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
# call custom success action if backup & maintenance were successful
|
||||||
|
if($null -ne $CustomActionEndSuccess) {
|
||||||
|
Invoke-Expression $CustomActionEndSuccess
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
# Save state to file
|
# Save state to file
|
||||||
Set-BackupState
|
Set-BackupState
|
||||||
|
|
||||||
|
|||||||
11
config.ps1
11
config.ps1
@@ -40,4 +40,13 @@ $SnapshotMaintenanceDays = 30
|
|||||||
$SnapshotDeepMaintenanceDays = 90
|
$SnapshotDeepMaintenanceDays = 90
|
||||||
|
|
||||||
# restic.exe self update configuration
|
# restic.exe self update configuration
|
||||||
$SelfUpdateEnabled = $true
|
$SelfUpdateEnabled = $true
|
||||||
|
|
||||||
|
# (optional) custom actions
|
||||||
|
# Define commands to pass to Invoke-Expression at script start and end
|
||||||
|
# note: Errors will only be reported if the script does not eventually succeed. Errors
|
||||||
|
# from unsuccessful attempts to backup or maintain the repository will not result
|
||||||
|
# in the custom error action being called unless all attempts failed.
|
||||||
|
$CustomActionStart = $null
|
||||||
|
$CustomActionEndError = $null
|
||||||
|
$CustomActionEndSuccess = $null
|
||||||
Reference in New Issue
Block a user