Update error and debug actions

This commit is contained in:
Yorick Barbanneau 2021-01-20 17:35:45 +01:00
parent 1397b77f49
commit 990c9eb249

View file

@ -13,7 +13,8 @@ $global:logfile = $false
$tmp_path = "$PSScriptRoot\tmp" $tmp_path = "$PSScriptRoot\tmp"
$global:bin_path = "$PSScriptRoot\bin" $global:bin_path = "$PSScriptRoot\bin"
$ProgressPreference = "SilentlyContinue" $ProgressPreference = "SilentlyContinue"
$ErrorActionPreference = "SilentlyContinue" $ErrorActionPreference = "Stop"
$DebugPreference = "SilentlyContinue"
if ( $debug ) { if ( $debug ) {
$DebugPreference = "Continue" $DebugPreference = "Continue"
@ -36,6 +37,7 @@ function json_to_hash () {
Write-Debug "Found value $_" Write-Debug "Found value $_"
$r[$_.Name] = $_.Value $r[$_.Name] = $_.Value
} }
Write-debug "End json_to_hash"
return $r return $r
} }
@ -197,8 +199,9 @@ $backup.actions | % {
} }
try { try {
Import-Module -Name "$PSScriptRoot\lib\backupscript-$($_.type).psm1" -Force Write-Debug "Import module $($_.type)"
Backup-Create -source $source -dest $destination -name $_.name -opt $opt #-EA Stop Import-Module -Name "$PSScriptRoot\lib\backupscript-$($_.type).psm1"
Backup-Create -source $source -dest $destination -name $_.name -opt $opt
if ( $_.psobject.properties.match('hook_postexec').Count -and $_.hook_postexec -ne "" ) { if ( $_.psobject.properties.match('hook_postexec').Count -and $_.hook_postexec -ne "" ) {
Set-Message "Postexec hook : execute $($_.hook_postexec)" Set-Message "Postexec hook : execute $($_.hook_postexec)"
Invoke-Expression $_.hook_postexec Invoke-Expression $_.hook_postexec