Solved

Backup report for 1 machine during for last year jobs

  • 23 February 2023
  • 7 comments
  • 134 views

Userlevel 1
  • New Here
  • 0 comments

Hello,
I am currently looking for a way to generate a report / extract of the backup execution status for 1 machine for the entire last year.

Is there a way to do this using Powershell, SQL or something else?

Thanks for your help

icon

Best answer by JMeixner 23 February 2023, 12:33

View original

7 comments

Userlevel 7
Badge +14

For starters, I would advise NOT to use the SQL database to achieve this. Basically I believe the database is off limits

 

If I remember correctly, the powershell comandlet Get-VBRBackupSession is the one you are looking for

Userlevel 7
Badge +5

Hi Rom,

do you know the Powershell tool “AsBuildReport” ?
I think you can use this for your goal.

Here the link: https://forums.veeam.com/powershell-f26/asbuiltreport-veeam-vbr-report-t78470.html

Best regards.

Userlevel 7
Badge +17

Yes, this is possible. If you keep the session info in the database for a year.

I have to look for the code, please give me some time.  I come back to you… 😎

Userlevel 7
Badge +17

So, I have found it finally… 😎

 

To get all backup sessions of the job in which the VM is included:

$reportstartdate = (Get-Date).AddYears(-1)

$reportstopdate = Get-Date

$VBRJob = "TestJob"

$sessions = get-vbrbackupsession | where { (($_.CreationTime -ge $reportstartdate -and $_.CreationTime -le $reportstopdate) -and ($_.JobName -eq $VBRJob)) } | sort Endtime

$sessions | select JobName, Endtime, Result

The get-vbrbackupsession takes some time to complete on a server with many backupjobs...

You can include the select statement in the first command, I did it in a separate step, because I need the complete data structure for the next step.

Output:

JobName  EndTime              Result

-------  -------              ------

TestJob  23.02.2022 23:36:23 Success

TestJob  24.02.2022 23:36:13 Success

TestJob  25.02.2022 23:35:34 Success

TestJob  26.02.2022 23:35:33 Success

TestJob  27.02.2022 23:36:35 Success

TestJob  28.02.2022 23:37:18 Success

TestJob  01.03.2022 23:39:14 Success

TestJob  02.03.2022 23:39:51 Success

...

TestJob  17.02.2023 23:33:42 Success

TestJob  18.02.2023 23:36:44 Success

TestJob  19.02.2023 23:33:32 Success

TestJob  20.02.2023 23:33:37 Success

TestJob  21.02.2023 23:36:46 Success

TestJob  22.02.2023 23:33:56 Success

To get the information about a specific VM inside the back session:

$VMName = "TestVM"

foreach ($session in ($sessions | ?{$_.IsRetryMode -eq $false}))

{

   $backupInfo = get-vbrtasksession -session $session | where { $_.Name -eq $VMName }

   $output = $session.Jobname+" "+$session.Endtime+" "+$backupinfo.Name+" "+$backupinfo.Status

   echo $output

}

 

Output:

TestJob 02/23/2022 23:36:23 TestVM Success

TestJob 02/24/2022 23:36:13 TestVM Success

TestJob 02/25/2022 23:35:34 TestVM Success

TestJob 02/26/2022 23:35:33 TestVM Success

TestJob 02/27/2022 23:36:35 TestVM Success

TestJob 02/28/2022 23:37:18 TestVM Success

TestJob 03/01/2022 23:39:14 TestVM Success

TestJob 03/02/2022 23:39:51 TestVM Success

...

TestJob 02/17/2023 23:33:42 TestVM Success

TestJob 02/18/2023 23:36:44 TestVM Success

TestJob 02/19/2023 23:33:32 TestVM Success

TestJob 02/20/2023 23:33:37 TestVM Success

TestJob 02/21/2023 23:36:46 TestVM Success

TestJob 02/22/2023 23:33:56 TestVM Success

There is many more information for the backup and task sessions, just play around with it to get all the information you need.

 

 

Userlevel 7
Badge +20

@JMeixner - that is a great find and thanks for sharing that.  Always automating! 😎

Userlevel 7
Badge +17

😎 No find, self written...

Userlevel 7
Badge +20

😎 No find, self written...

Yeah, I did not mean you searched for it just you found a way to retrieve the data. 😉

Comment