I need a way to prevent Veeam replication jobs from running based on the free space available at the targer datastore.
We've had some serious issues where storage was increased by a lot on a production vm and it depleted the free space on the target datastore.
This caused corruption of some very large replicas and severe delays in getting everything running again.
I tried powershell scripts that were supposed to disable or stop the job after checking the free space on the datastore but no configuration so far was able to stop the job from running.
Is there a way to actually do this?
-
dimaslan
- Service Provider
- Posts: 119
- Liked: 9 times
- Joined: Jul 01, 2017 8:02 pm
- Full Name: Dimitris Aslanidis
- Contact:
-
david.domask
- Veeam Software
- Posts: 3068
- Liked: 710 times
- Joined: Jun 28, 2016 12:12 pm
- Contact:
Re: How to prevent Veeam replications from running
Hi Dimitris,
The Backup Server has some configuration / protection options for datastore free space, but this is a global setting and probably won't be as granular as you like.
Is the space increase on the production VM unexpected? Thing is that you have two events you're needing to monitor here:
- Production VM size increases
- Free space remaining on target datastore
The KB above can set an overall datastore free space warning threshold and ought help in many cases, but to be more granular it would probably be best to do with Veeam One Alarm remediation actions or a powershell script running in the background that disables the job.
You mentioned you tried a powershell script, can you share more details on what you configured? Was it a pre-job script attached to the replication job or how was it configured?
The Backup Server has some configuration / protection options for datastore free space, but this is a global setting and probably won't be as granular as you like.
Is the space increase on the production VM unexpected? Thing is that you have two events you're needing to monitor here:
- Production VM size increases
- Free space remaining on target datastore
The KB above can set an overall datastore free space warning threshold and ought help in many cases, but to be more granular it would probably be best to do with Veeam One Alarm remediation actions or a powershell script running in the background that disables the job.
You mentioned you tried a powershell script, can you share more details on what you configured? Was it a pre-job script attached to the replication job or how was it configured?
David Domask | Product Management: Principal Analyst
-
dimaslan
- Service Provider
- Posts: 119
- Liked: 9 times
- Joined: Jul 01, 2017 8:02 pm
- Full Name: Dimitris Aslanidis
- Contact:
Re: How to prevent Veeam replications from running
The script is this:
# Define the target datastore and threshold (GB)
$datastoreName = "BKP-LUN02"
$thresholdGB = 5000000
# Get datastore free space
$datastore = Get-Datastore -Name $datastoreName
$freeSpaceGB = [math]::Round($datastore.FreeSpaceMB / 1024, 2)
# Define replication job name
$jobName = "VM01 Replication"
# Check free space
if ($freeSpaceGB -lt $thresholdGB) {
Write-Host "Insufficient space on datastore: $datastoreName. Free space: $freeSpaceGB GB (Threshold: $thresholdGB GB). Stopping job."
# Get the replication job
$job = Get-VBRJob | Where-Object {$_.Name -eq $jobName}
# Abort the job if it's running
if ($job) {
# Stop the job session explicitly
$session = Get-VBRBackupSession | Where-Object {$_.JobName -eq $jobName -and $_.State -eq "Working"}
if ($session) {
Stop-VBRBackupSession -Session $session
Write-Host "Replication job session '$jobName' has been stopped due to insufficient space."
} else {
Write-Host "No active session found for replication job '$jobName'."
}
} else {
Write-Host "Replication job '$jobName' not found."
}
Exit 1 # Exit with failure code
} else {
Write-Host "Sufficient space available: $freeSpaceGB GB. Job will proceed."
Exit 0 # Exit with success code
}
I deliberately set a very high threshold to test it but it still doesn't stop the job. Obviously I have ommited the initial step with the connection creds to the vcenter.
# Define the target datastore and threshold (GB)
$datastoreName = "BKP-LUN02"
$thresholdGB = 5000000
# Get datastore free space
$datastore = Get-Datastore -Name $datastoreName
$freeSpaceGB = [math]::Round($datastore.FreeSpaceMB / 1024, 2)
# Define replication job name
$jobName = "VM01 Replication"
# Check free space
if ($freeSpaceGB -lt $thresholdGB) {
Write-Host "Insufficient space on datastore: $datastoreName. Free space: $freeSpaceGB GB (Threshold: $thresholdGB GB). Stopping job."
# Get the replication job
$job = Get-VBRJob | Where-Object {$_.Name -eq $jobName}
# Abort the job if it's running
if ($job) {
# Stop the job session explicitly
$session = Get-VBRBackupSession | Where-Object {$_.JobName -eq $jobName -and $_.State -eq "Working"}
if ($session) {
Stop-VBRBackupSession -Session $session
Write-Host "Replication job session '$jobName' has been stopped due to insufficient space."
} else {
Write-Host "No active session found for replication job '$jobName'."
}
} else {
Write-Host "Replication job '$jobName' not found."
}
Exit 1 # Exit with failure code
} else {
Write-Host "Sufficient space available: $freeSpaceGB GB. Job will proceed."
Exit 0 # Exit with success code
}
I deliberately set a very high threshold to test it but it still doesn't stop the job. Obviously I have ommited the initial step with the connection creds to the vcenter.
-
david.domask
- Veeam Software
- Posts: 3068
- Liked: 710 times
- Joined: Jun 28, 2016 12:12 pm
- Contact:
Re: How to prevent Veeam replications from running
Kk, and are you running this as a pre-job script or as some background script?
Also, Stop-VBRBackupSession is not a Veeam cmdlet -- is it possible you had some custom function you wrote that this utilizes?
In short, I suspect you're setting this as a pre-job script, and even with correct cmdlets, I don't advise doing it this way. Instead, consider using Veeam One Alarms and set a custom remediation action that scripts disabling the Replica jobs, or set a script to run on the backup server itself as a scheduled task that checks the datastore free-space and alerts on low free space + disables the jobs.
The built-in datastore threshold options I linked before can help, but if you want it more granular then the above two options are best.
Also, Stop-VBRBackupSession is not a Veeam cmdlet -- is it possible you had some custom function you wrote that this utilizes?
In short, I suspect you're setting this as a pre-job script, and even with correct cmdlets, I don't advise doing it this way. Instead, consider using Veeam One Alarms and set a custom remediation action that scripts disabling the Replica jobs, or set a script to run on the backup server itself as a scheduled task that checks the datastore free-space and alerts on low free space + disables the jobs.
The built-in datastore threshold options I linked before can help, but if you want it more granular then the above two options are best.
David Domask | Product Management: Principal Analyst
-
dimaslan
- Service Provider
- Posts: 119
- Liked: 9 times
- Joined: Jul 01, 2017 8:02 pm
- Full Name: Dimitris Aslanidis
- Contact:
Re: How to prevent Veeam replications from running
This is set as a pre-job script.
There is a Veeam ONE server so we will look into how to do this there.
There is a Veeam ONE server so we will look into how to do this there.
Who is online
Users browsing this forum: No registered users and 4 guests