I'm struggling with adding Pre/Post freeze scripts to a Windows Agent Protection Group in app aware settings of a Windows Agent Job.
All ideas Veeam AI delivers to me are not functional.
Code: Select all
# Define the name of the backup job and the pre-freeze script path
$jobName = "Windows Agent Backup Job"
$preFreezeScriptPath = "C:\Scripts\PreFreezeScript.ps1"
# Get the backup job
$job = Get-VBRComputerBackupJob -Name $jobName
# Get the protection group
$protectionGroup = Get-VBRProtectionGroup -Name "Windows Servers"
# Get the application aware settings
$appAwareSettings = $protectionGroup.Options.ApplicationAwareProcessing
# Define the pre-freeze script
$appAwareSettings.PreFreezeScript = $preFreezeScriptPath
# Apply the updated settings to the protection group
Set-VBRProtectionGroupOptions -ProtectionGroup $protectionGroup -Options $protectionGroup.Options
Write-Output "Pre-Freeze Script has been defined for the protection group: Windows Servers"
$protectionGroup.Options.ApplicationAwareProcessing is not a valid sub property
I got lot of these, where either invalid sub properties are used, or incompatible cmdlets where chained.
My latest personal approach was this here
Code: Select all
# Setting Pre/Post Scripts in Backup Job
$paramNewVBRScriptProcessingOptions = @{
ScriptPrefreezeCommand = "D:\VeeamScripts\preFreeze.bat"
ScriptPostthawCommand = "D:\VeeamScripts\postFreeze.bat"
ProcessingAction = 'IgnoreFailures'
}
$ErrorObject | Add-Member -Force -NotePropertyName paramNewVBRScriptProcessingOptions -NotePropertyValue $paramNewVBRScriptProcessingOptions
$scriptOptions = New-VBRScriptProcessingOptions @paramNewVBRScriptProcessingOptions
# $JobOptions = Set-VBRApplicationProcessingOptions -ScriptProcessingOptions $scriptOptions
#$pgInJob = Get-VBRJobObject -Job $job #| Where-Object { $_.Name -eq $ProtectionGroupParams['Name'] }
$pgInJob = Get-VBRProtectionGroup -Name $ProtectionGroupParams['Name']
$ProcessOptions = New-VBRApplicationProcessingOptions -BackupObject $pgInJob -Enable -ScriptProcessingOptions $scriptOptions -OSPlatform Windows -GeneralTransactionLogAction ProcessLogsWithJob
$null = Set-VBRApplicationProcessingOptions -Options $ProcessOptions -Enable -GeneralTransactionLogAction ProcessLogsWithJob
$AllRes += Write-CSDLog -LogText "$($MyInvocation.MyCommand)~Created Pre/Post Script object" -Severity I -Object $TemplateJob
$null = Enable-VBRComputerBackupJob -Job $job
$AllRes += Write-CSDLog -LogText "$($MyInvocation.MyCommand)~Job enabled" -Severity I -Object $TemplateJob
Any ideas what I'm doing wrong?