I'm currently facing an issue with setting up pre-job and post-job scripts in Veeam.
My goal is to use these scripts to achieve a simple air gap mechanism.
Setup Overview:
1.I configured a Linux server to mount an NFS share.
2.In VBR, I added a Linux-based repository, pointing to the mounted folder.
3.On the Linux server, I created two shell scripts:
- mount.sh – for mounting the share
#!/bin/bash
# NFS for Veeam Pre-Job
MOUNT_POINT="/veeam"
NFS_SERVER="192.168.10.22"
NFS_SHARE="/ifs/veeam"
logger "[Veeam Pre-Job]"
if mountpoint -q "$MOUNT_POINT"; then
logger "[Veeam Pre-Job]"
exit 0
fi
logger "[Veeam Pre-Job] NFS $NFS_SERVER:$NFS_SHARE 到 $MOUNT_POINT"
mkdir -p "$MOUNT_POINT"
sudo mount -t nfs "$NFS_SERVER:$NFS_SHARE" "$MOUNT_POINT"
if [ $? -ne 0 ]; then
logger "[Veeam Pre-Job] if fail"
exit 1
fi
logger "[Veeam Pre-Job] if finish"
- umount.sh – for unmounting it
- mount.ps1 and umount.ps1 — both scripts use SSH to trigger the corresponding shell scripts on the Linux server.
When I manually run the PowerShell scripts, they successfully connect and execute the mount/unmount actions via SSH.# call_mount_ssh.ps1 - Mount NFS share on Linux via SSH
$log = "D:\scripts\call_mount_ssh.log"
$outFile = "D:\scripts\call_mount_ssh.log.out"
$errFile = "D:\scripts\call_mount_ssh.log.err"
$ssh = "C:\Windows\System32\OpenSSH\ssh.exe"
$linuxUser = "user1"
$linuxHost = "192.168.10.9"
$remoteScript = "/opt/veeam/scripts/mount_nfs.sh"
"[$(Get-Date)] Starting SSH mount script" | Out-File $log
#fingerprint prompt
$sshCommand = @(
"-o", "StrictHostKeyChecking=no",
"-o", "ConnectTimeout=30",
"$linuxUser@$linuxHost",
$remoteScript
)
"[$(Get-Date)] Executing: ssh $($sshCommand -join ' ')" | Add-Content $log
try {
$process = Start-Process -FilePath $ssh `
-ArgumentList $sshCommand `
-NoNewWindow -Wait -PassThru `
-RedirectStandardOutput $outFile `
-RedirectStandardError $errFile
$exitCode = $process.ExitCode
Add-Content $log "`n--- STDOUT ---`n$(Get-Content $outFile -ErrorAction SilentlyContinue)"
Add-Content $log "`n--- STDERR ---`n$(Get-Content $errFile -ErrorAction SilentlyContinue)"
Add-Content $log "`nExit code: $exitCode"
exit $exitCode
}
catch {
Add-Content $log "`nException: $($_.Exception.Message)"
exit 1
}
I’ve also confirmed that the account used has sufficient permissions to mount the NFS share, so permission does not appear to be the root cause.
Problem:
When I assign these scripts as Pre-job and Post-job scripts in the Veeam backup job, they consistently fail with a timeout error.
Questions:<17> Info (3) Executing custom command [powershell.exe], arguments [ -ExecutionPolicy ByPass -Command " try {& 'D:\scripts\call_mount_ssh.ps1' -ErrorAction Stop } catch { exit 1 } "]
[08.05.2025 16:18:20.752] <17> Warning (3) Pre-job script timed out
[08.05.2025 16:18:20.815] <17> Warning (3) Pre-job script timed out
Am I missing any required configuration ?
Are there limitations when using PowerShell scripts to trigger remote SSH calls from within a job context?
Any guidance or best practice recommendation would be greatly appreciated.
Thank you!