Veeam Software Appliance does not allow you to do as deep tests with SureBackup as you are able to do with Windows based Backup & Replication, due to fact that appliance is hardened and you cannot install any extra tools to it. So I built a workaround that allows you to test applications even when you are using Veeam Software Appliance.
In this blog post, I show how you can do database-aware SureBackup testing on the Veeam Software Appliance with a small Rocky Linux helper, SSH and two query tools.
DISCLAIMER: This is not supported by Veeam. It is a personal lab proof of concept, not a Veeam solution or product. Use this guide at your own risk, and test it in a lab before you go anywhere near production.
You are also expected to know how SureBackup testing works, this is not a guide to setup SureBackup. Documentation for SureBackup can be found from: https://helpcenter.veeam.com/docs/vbr/userguide/surebackup_recovery_verification.html?ver=13
Lab background
Before we start building, here's the lab this post is based on. You'll need to swap these names and addresses for your own, but it hopefully helps to understand what I have done.
Demo application in my lab
LabApp is a small virtual machine that runs a test application. Once a minute it writes a timestamp row to two databases, one on PostgreSQL and one on Microsoft SQL Server. This gives us data that keeps changing, so we can check more than "the database started". We can also check that it holds recent data and that new rows keep arriving.
Both database engines use the same layout:
Database name: testdb PostgreSQL table: test_log
MSSQL table: dbo.test_log
Timestamp column (both engines): created_at
LabDB is the server that hosts both database engines. It's the machine we actually want to verify with SureBackup.
The machines and addresses:
Veeam Backup & Replication (Veeam Software Appliance): 10.10.10.70
SureBackup Virtual Lab proxy appliance: 10.10.10.80
Rocky Linux helper appliance (built in this post): 10.10.10.75
LabDB (PostgreSQL and MSSQL): 10.10.11.101
LabApp (test application): 10.10.14.25
The Virtual Lab I created for the SureBackup job has two isolated networks, matching production: 10.10.11.0/24 for LabDB and 10.10.14.0/24 for LabApp.
Since I don't even run ping tests with my SureBackup job, the only network that matters from outside the lab is the database network. Its masquerade network is 10.255.253.0, so inside the running lab, LabDB can be reached at 10.255.253.101. The Virtual Lab proxy at 10.10.10.80 translates that address back to 10.10.11.101 inside the isolated network.
Rocky Linux helper appliance is not part of the Virtual Lab. It stays in the production network and reaches LabDB only through the masquerade address. That's why the static route covered later in this post is mandatory.
Why startup order matters
The database check doesn't just look for rows. It looks for recent rows. If only LabDB were started in the Virtual Lab, the newest rows would be as old as the backup, and the check would fail as soon as the restore point was more than a few minutes old.
That's why LabApp has to start first. Once it's running inside the lab, it writes a fresh timestamp every minute to the restored databases on LabDB. When SureBackup gets to LabDB and runs our scripts, new rows have already arrived, and the check confirms the recovered database works end to end, not just that it boots.
In practice, LabApp goes before LabDB in the SureBackup startup order, and LabDB's custom test scripts run only after LabApp is up and writing data.
The idea
Veeam Software Appliance is hardened, and I cannot install database clients on it. So the appliance only does the minimum: SureBackup runs a small wrapper script, the wrapper connects over SSH to a Linux helper appliance, and the helper runs the actual database query against the recovered VM.
SureBackup job (passes %vm_ip%)
-> wrapper script on Veeam Software Appliance
-> SSH -> Rocky Linux helper appliance
-> static route -> Virtual Lab proxy (masquerade IP)
-> recovered database VM
The helper stays outside the Virtual Lab. It is not in the Application Group and it is never restored from backup.
A word about the scripts
The scripts in this post are purposely not built securely. Database credentials are written in plain text inside the helper scripts, host key checking is turned off and the SSH key has no passphrase. That is a deliberate choice: the goal is to keep everything as simple as possible and prove the concept. Treat this as a proof of concept, not a market-ready product. If you take the idea further, use a read-only database login at the very least, and harden credential handling and SSH trust.
Part 1: Build the helper appliance
My helper is a Rocky Linux 9.6 VM (2 vCPU, 2 GB RAM, 16 GB disk) with a static IP in the same production network as the Virtual Lab proxy appliance. The Veeam Software Appliance must reach it on TCP 22.
Patch it, make sure SSH is enabled and create a user and folder for the checks (sbcheck is just my example name):
sudo dnf -y update
sudo dnf -y install openssh-server curl
sudo systemctl enable --now sshd
sudo useradd -m sbcheck
sudo -u sbcheck mkdir -p /home/sbcheck/scripts You might also want to use passwd to set password for your sbcheck user 😀
Install the PostgreSQL client (psql). The AppStream version is fine for simple queries:
sudo dnf -y install postgresql
psql --version
Install the SQL Server command-line tools (sqlcmd) from the Microsoft repository:
curl -sSL https://packages.microsoft.com/config/rhel/9/prod.repo | sudo tee /etc/yum.repos.d/mssql-release.repo
sudo ACCEPT_EULA=Y dnf -y install mssql-tools18 unixODBC-devel
/opt/mssql-tools18/bin/sqlcmd -?
Helper check scripts
Each script takes the database address as its first argument, prints an OK or FAIL line and exits 0 only when the test passes. My example checks that a table has at least 10 rows and that the newest row is no older than 15 minutes. Replace the query with whatever proves health for your application.
/home/sbcheck/scripts/check-postgresql.sh:
#!/usr/bin/env bash
#REMEMBER TO CHANGE VARIABLES
TARGET="$1"
DB_PORT="5432"
DB_NAME="testdb"
DB_USER="postgres"
DB_PASS="password"
TABLE="test_log"
TS_COLUMN="created_at"
MIN_ROWS=10
MAX_AGE_SECONDS=900
if [[ -z "$TARGET" ]]; then
echo "FAIL: Target IP was not supplied"
exit 1
fi
DB_URI="postgresql://$DB_USER:$DB_PASS@${TARGET}:$DB_PORT/$DB_NAME"
RESULT=$(
psql \
--no-psqlrc \
--quiet \
--tuples-only \
--no-align \
--set ON_ERROR_STOP=1 \
--dbname="$DB_URI" \
--command="
SELECT
COUNT(*)::text || '|' ||
COALESCE(
EXTRACT(EPOCH FROM (CURRENT_TIMESTAMP - MAX(created_at)))::bigint::text,
'NULL'
)
FROM (
SELECT "$TS_COLUMN"
FROM "$TABLE"
ORDER BY "$TS_COLUMN" DESC
LIMIT "$MIN_ROWS"
) AS latest_rows;
" 2>&1
)
PSQL_RC=$?
if [[ $PSQL_RC -ne 0 ]]; then
echo "FAIL: PostgreSQL query failed"
echo "$RESULT"
exit 1
fi
RESULT=$(printf '%s' "$RESULT" | tr -d '[:space:]')
IFS='|' read -r ROW_COUNT AGE_SECONDS <<< "$RESULT"
if [[ ! "$ROW_COUNT" =~ ^[0-9]+$ ]]; then
echo "FAIL: PostgreSQL returned an invalid row count: $ROW_COUNT"
exit 1
fi
if [[ ! "$AGE_SECONDS" =~ ^-?[0-9]+$ ]]; then
echo "FAIL: PostgreSQL returned an invalid timestamp age: $AGE_SECONDS"
exit 1
fi
if [[ "$ROW_COUNT" -ne 10 ]]; then
echo "FAIL: PostgreSQL returned $ROW_COUNT rows; expected 10"
exit 1
fi
if [[ "$AGE_SECONDS" -lt 0 ]]; then
echo "FAIL: Newest PostgreSQL row is in the future by $((-AGE_SECONDS)) seconds"
exit 1
fi
if [[ "$AGE_SECONDS" -gt "$MAX_AGE_SECONDS" ]]; then
echo "FAIL: Newest PostgreSQL row is $AGE_SECONDS seconds old; maximum is 900 seconds"
exit 1
fi
echo "OK: PostgreSQL returned 10 rows and newest row is $AGE_SECONDS seconds old"
exit 0
/home/sbcheck/scripts/check-mssql.sh:
#!/usr/bin/env bash
TARGET="$1"
if [[ -z "$TARGET" ]]; then
echo "FAIL: Target IP was not supplied"
exit 1
fi
#REMEMBER TO CHANGE VARIABLES
SQL_SERVER="${TARGET}"
SQL_DATABASE="testdb"
SQL_USER="sa"
SQL_PASSWORD="password"
SQL_TABLE="dbo.test_log"
SQL_COLUMN="created_at"
MIN_ROWS=10
MAX_AGE_SECONDS=900
RESULT=$(
sqlcmd \
-S "$SQL_SERVER" \
-d "$SQL_DATABASE" \
-U "$SQL_USER" \
-P "$SQL_PASSWORD" \
-C \
-b \
-h -1 \
-W \
-Q "
SET NOCOUNT ON;
WITH latest_rows AS
(
SELECT TOP (10) "$SQL_COLUMN"
FROM "$SQL_TABLE"
ORDER BY "$SQL_COLUMN" DESC
)
SELECT
CONCAT(
COUNT_BIG(*),
'|',
COALESCE(
CONVERT(
varchar(30),
DATEDIFF_BIG(SECOND, MAX("$SQL_COLUMN"), SYSDATETIME())
),
'NULL'
)
)
FROM latest_rows;
" 2>&1
)
SQLCMD_RC=$?
if [[ $SQLCMD_RC -ne 0 ]]; then
echo "FAIL: SQL Server query failed"
echo "$RESULT"
exit 1
fi
RESULT=$(printf '%s\n' "$RESULT" |
sed '/^[[:space:]]*$/d' |
tail -n 1 |
tr -d '[:space:]')
IFS='|' read -r ROW_COUNT AGE_SECONDS <<< "$RESULT"
if [[ ! "$ROW_COUNT" =~ ^[0-9]+$ ]]; then
echo "FAIL: SQL Server returned an invalid row count: $ROW_COUNT"
echo "Raw result: $RESULT"
exit 1
fi
if [[ ! "$AGE_SECONDS" =~ ^-?[0-9]+$ ]]; then
echo "FAIL: SQL Server returned an invalid timestamp age: $AGE_SECONDS"
echo "Raw result: $RESULT"
exit 1
fi
if [[ "$ROW_COUNT" -ne "$MIN_ROWS" ]]; then
echo "FAIL: SQL Server returned $ROW_COUNT rows; expected $MIN_ROWS"
exit 1
fi
if [[ "$AGE_SECONDS" -lt 0 ]]; then
echo "FAIL: Newest SQL Server row is in the future by $((-AGE_SECONDS)) seconds"
exit 1
fi
if [[ "$AGE_SECONDS" -gt "$MAX_AGE_SECONDS" ]]; then
echo "FAIL: Newest SQL Server row is $AGE_SECONDS seconds old; maximum is 900 seconds"
exit 1
fi
echo "OK: SQL Server returned 10 rows and newest row is $AGE_SECONDS seconds old"
exit 0Part 2: Static routing is mandatory
During a SureBackup run the recovered VM is reachable from outside only through its masquerade address (10.255.253.x in my lab), and only via the Virtual Lab proxy appliance. Veeam adds that route on the backup server automatically, but the helper appliance gets no such help. Without a static route the helper sends the traffic to its default gateway and every test times out, even though the lab is healthy. The static route on the helper is not optional.
Test with a temporary route first. The output of ip route get must show the Virtual Lab proxy as next hop:
sudo ip route add <masquerade-network>/<prefix> via <virtual-lab-proxy-production-ip>
ip route get <masquerade-ip-of-db-vm>
Then make it persistent with NetworkManager (find the connection name with nmcli connection show):
sudo nmcli connection modify <connection-name> +ipv4.routes "<masquerade-network>/<prefix> <virtual-lab-proxy-production-ip>"
sudo nmcli connection up <connection-name>
If you change or rebuild the Virtual Lab, the route on the helper has to change with it.
Part 3: Create SSH keys
For connection from Veeam Software Appliance to our Helper Appliance, we need to create a ssh-key and copy it temporarily to your workstation. To create ssh-key, run following commands as sbcheck user (or whatever user account you are using):
ssh-keygen -t rsa -b 4096 -f ~/dbcheck_rsa -N "" -C "vsa-surebackup"
mkdir -p ~/.ssh && chmod 700 ~/.ssh
cat ~/dbcheck_rsa.pub >> ~/.ssh/authorized_keys
chmod 600 ~/.ssh/authorized_keys
After creating keys, use WinSCP or similar tool to copy dbcheck_rsa to your workstation, we will copy it to Veeam Software Appliance on next step.
Part 4: The minimum on the Veeam Software Appliance
The appliance side is one SSH key and two small wrapper scripts. Nothing is installed.
Create the wrapper scripts
The wrappers are the only scripts that live on the Veeam Software Appliance. They receive the masquerade address from SureBackup, call the right check on the helper and pass the exit code back. Remember to set IP-address of helper appliance on script! When you create script files, make sure to use Unix style End Of Line (LF) instead of Windows style (CR LF).
Adjust variables to match your environment
check-postgresql.sh
#!/usr/bin/env bash
TARGET_IP="$1"
SSH="/usr/bin/ssh"
KEY="/var/lib/veeam/scripts/RemoteScript/dbcheck_rsa"
#REMEMBER TO CHANGE YOUR HOST IP
HOST="sbcheck@10.10.10.75"
REMOTE_SCRIPT="/home/sbcheck/scripts/check-postgresql.sh"
if [[ -z "$TARGET_IP" ]]; then
echo "FAIL: SureBackup did not supply target IP"
exit 1
fi
"$SSH" \
-n \
-i "$KEY" \
-o IdentitiesOnly=yes \
-o UserKnownHostsFile=/dev/null \
-o StrictHostKeyChecking=no \
-o BatchMode=yes \
-o ConnectTimeout=10 \
"$HOST" \
"sh $REMOTE_SCRIPT $TARGET_IP"
RC=$?
echo "Remote script exit code: $RC"
if [ "$RC" -eq 0 ]; then
exit 0
fi
exit 1
check-mssql.sh
#!/usr/bin/env bash
TARGET_IP="$1"
SSH="/usr/bin/ssh"
KEY="/var/lib/veeam/scripts/RemoteScript/dbcheck_rsa"
#REMEMBER TO CHANGE YOUR HOST IP
HOST="sbcheck@10.10.10.75"
REMOTE_SCRIPT="/home/sbcheck/scripts/check-mssql.sh"
if [[ -z "$TARGET_IP" ]]; then
echo "FAIL: SureBackup did not supply target IP"
exit 1
fi
"$SSH" \
-n \
-i "$KEY" \
-o IdentitiesOnly=yes \
-o UserKnownHostsFile=/dev/null \
-o StrictHostKeyChecking=no \
-o BatchMode=yes \
-o ConnectTimeout=10 \
"$HOST" \
"sh $REMOTE_SCRIPT $TARGET_IP"
RC=$?
echo "Remote script exit code: $RC"
if [ "$RC" -eq 0 ]; then
exit 0
fi
exit 1
Copy files to Veeam Software Appliance
Use Veeam Backup & Replication Console to copy these files to Appliance. Go to 'Files' view and use it to create RemoteScript folder in the appliance under the folder 'scripts' and copy both check-mssql.sh and check-postgresql.sh to that folder. Also, copy dbcheck_rsa to the same folder to allow SSH connection to work. It should look like this:
Part 5: Test manually if script works
If you want to do manual testing, you can log in with SSH to appliance as veeamadmin (or other account with similar privileges). Documentation on how to enable SSH access to appliance: https://helpcenter.veeam.com/docs/vbr/em/hmc_configure_remote_access.html?ver=13#access_ssh
You can use following command to test if script works. Use your production DB ip address to test the script (assuming your Veeam Software Appliance can reach it)
sh /var/lib/veeam/scripts/RemoteScript/check-postgresql.sh "db-ip"; echo $?A successful run should look something similar to this:
Part 6: Using scripts in SureBackup job
In the Application Group (or the linked job settings), open the verification options of the database VM, enable the custom script and point it to the wrapper on the appliance. In the Arguments field enter: %vm_ip% SureBackup replaces %vm_ip% with the masquerade address of the recovered VM. Official documentation can be found from: https://helpcenter.veeam.com/docs/vbr/userguide/custom_verification_scripts.html?ver=13
Last words
When I realized that it is not possible to run SQL queries or other advanced testing methods with Veeam Software Appliance (like it is documented in here: https://helpcenter.veeam.com/docs/vbr/userguide/predefined_tests.html?ver=13#microsoft-sql-server-checker-script) I had some sort of "hold my beer" moment.
And after some trials and errors (with big help from AI), I was able to make this work.
Same logic should also work with pre/post scripts, even though I have not tested it. As an example, you might have NAS storage where Veeam does not have native integration, but you want to use its native snapshot functionality when doing backup. Maybe you could use similar logic, to connect to NAS storage with SSH and execute snapshot creation as a batch job with pre job script?
Make sure to read scripts before using them and change variables to match your environment. You most likely wont have similar application / DB structure to test, so you need to build your own queries. But hopefully this gives you a starting point.



