Availability for the Always-On Enterprise
Post Reply
Unison
Enthusiast
Posts: 87
Liked: 16 times
Joined: Feb 17, 2012 6:02 am
Full Name: Gav
Contact:

Backup Job RESULT Detail Report/Email

Post by Unison » Jul 08, 2018 10:46 pm

Hi guys,
does anyone know of a way to get the email result/report for a backup job to display the backup drive NAME that the backup files landed on?

Reason for asking is we have a backup job using a set of rotating USB drives - each one of the USB drives has a different 'name'. When the backup job completes, the normal result email comes around showing the details of the job run but there is nothing in the email/history to show what drive name the backup landed on.

Maybe this is a 'feature request' - to display the destination drive/location name somewhere in the backup job history/email alert so that it is possible to identify which USB drive had a particularity backup point on it and also so that we can confirm daily that USB drives are being rotated.

v.Eremin
Veeam Software
Posts: 15209
Liked: 1146 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Backup Job RESULT Detail Report/Email

Post by v.Eremin » Jul 09, 2018 1:22 pm

Currently, it's not possible, but thank you for your feature request.

If you want to have custom report, you can combine one using PowerShell: Veeam snap-in allows you get information from job session log and Windows PowerShell helps you to identify name of the drive plugged in.

Thanks.

billcouper
Service Provider
Posts: 56
Liked: 13 times
Joined: Dec 18, 2017 8:58 am
Full Name: Bill Couper
Contact:

Re: Backup Job RESULT Detail Report/Email

Post by billcouper » Jul 11, 2018 11:33 am

Unison, check out this reply from Tom in another thread:
https://forums.veeam.com/veeam-backup-r ... ml#p141481
It's a few years old now so it might not work any more.

Basically, you could run a Job Script after the job (in the Storage-Advanced settings of the job).
If the code from that forum post works something like this is probably what I would do: (I have not tested this)

Code: Select all

# Load the veeam snapin
Add-PsSnapIn veeampssnapin

# Get the backup job name and last result
$parentpid = (Get-WmiObject Win32_Process -Filter "processid='$pid'").parentprocessid.ToString()
$parentcmd = (Get-WmiObject Win32_Process -Filter "processid='$parentpid'").CommandLine
$job = Get-VBRJob | ?{$parentcmd -like "*"+$_.Id.ToString()+"*"}
$jobname = $job.name
$jobresult = $job.GetLastResult()

# Get the name of the USB Drive attached that matches "VBR*"
$drivename = (Get-Volume | ? { $_.FileSystemLabel -ilike "VBR*" }).FileSystemLabel

# Message contents
$Body = @"
<p><b>Backup Job Finished</b></p>
<p><b>Job:</b> $jobname</p>
<p><b>Result:</b> $jobresult</p>
<p><b>Drive:</b> $drivename</p>
"@

# Send email notification
Send-MailMessage -smtpserver 'relay.domain.com' -from 'veeam@server.domain.com' -to 'admin@domain.com' -subject 'Backup Job Finished' -bodyashtml -body $Body
That works if there is one USB attached and it matches the predefined naming convention.
To get trickier you can add this line after the $job* stuff to get the session details, and then dig deeper into that object to get more information, however getting backup sessions tends to takes a long time (for me at least) so I avoid it wherever possible.

Code: Select all

$session = Get-VBRBackupSession | ?{($_.OrigJobName -eq $job.Name) -and ($parentcmd -like "*"+$_.Id.ToString()+"*")}

Unison
Enthusiast
Posts: 87
Liked: 16 times
Joined: Feb 17, 2012 6:02 am
Full Name: Gav
Contact:

Re: Backup Job RESULT Detail Report/Email

Post by Unison » Jul 13, 2018 12:23 am

Thanks Bill
I created a bat file to launch this powershell script - this Script you provided with a little tweaking WORKS when i run it outside of Veeam (run as administrator on the bat file) - obviously doent grab any veeam job details running outside of veeam but it does grab the currently connected USB drive name and also successfully fires off an email.

However when i tell the veeam job to execute this BAT file......the job runs ans shows that it 'executed script successfully'......however no result/email comes from the scrip when veeam runs it.

I also tried this construct for the bat file (https://www.veeam.com/kb2183) but that does not get it working.
i added the error output to a txt file as in the above article but that just resulted in an empty txt file so assuming no errors are being reported.


Anyone know how to get veeam to run this script as 'run as administrator' - or any other ideas why this script works when run manually, but not when you ask veeam to run it?

billcouper
Service Provider
Posts: 56
Liked: 13 times
Joined: Dec 18, 2017 8:58 am
Full Name: Bill Couper
Contact:

Re: Backup Job RESULT Detail Report/Email

Post by billcouper » Jul 13, 2018 12:47 am

Veeam can run the powershell script directly, change the file-type drop down menu to powershell and it will let you select it. That might help?

v.Eremin
Veeam Software
Posts: 15209
Liked: 1146 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Backup Job RESULT Detail Report/Email

Post by v.Eremin » Jul 13, 2018 3:07 pm

Anyone know how to get veeam to run this script as 'run as administrator' - or any other ideas why this script works when run manually, but not when you ask veeam to run it?
Try to execute the .bat manually with Veeam service account (account under which Veeam service runs) and see whether everything goes as expected. Most likely, the script will fail due to lack of permissions.

So, either grant those to Veeam service account or change the account altogether.

Thanks.

Post Reply

Who is online

Users browsing this forum: Bing [Bot], gisle_hagen and 71 guests