PowerShell script exchange
Post Reply
PeterLouwerse
Service Provider
Posts: 4
Liked: never
Joined: Aug 09, 2012 8:06 am
Full Name: Peter Louwerse
Contact:

Location of BackupSync session info in Veeam DB

Post by PeterLouwerse » Jan 22, 2019 2:13 pm

Hi All,

First time posting so I hope I'm doing it right.

I've created a script to report the size of individual sessions (full, inc,...) of individual VM's. I've been able to get the data for the Backup and Replication job types using the ReportSessionsView in the Veeam DB and then getting the data for the individual VM's from the ReportSessionInfoView. The data for the individual VM's for the BackupSync sessions is also visible but the session_id in those rows does not correspond to any session id in ReportSessionsView. The BackupSync jobs are simply not registered in the ReportSessionsView. Where (in the Veeam DB) is the BackupSync session data registered?

To give an idea of what I'm doing, here a piece of the script:

Code: Select all

    # Query the Veeam DB for all succesfull job sessions ([result] = '0')
    $SQLQuerySession = "SELECT [id],[creation_time],[end_time],[result],[total_size],[stored_size] `
        FROM [VeeamBackup].[dbo].[ReportSessionsView] `
        WHERE [job_name] = '" + $VeeamJob.Name + "' and [result] = '0' `
        ORDER BY [creation_time] asc;"

    $VeeamSessions = Invoke-Sqlcmd -Query $SQLQuerySession -ServerInstance "<DB Instance>"
        
    # Retrieve the VM information for each session 
    ForEach ($VeeamSessionID in $VeeamSessions.ID)
    {
        $SQLQueryInfo = "SELECT [id],[creation_time],[object_name],[total_size],[stored_size] `
            FROM [VeeamBackup].[dbo].[ReportSessionInfoView] `
            WHERE [session_id] = '" + $VeeamSessionID + "';"        $VeeamSessionInfo = Invoke-Sqlcmd -Query $SQLQueryInfo -ServerInstance "<DB Instance>"

        # Put the data per VM in the output object but only the data of which restore points are still available
        ForEach ($VeeamVMInfo in $VeeamSessionInfo)
Thanks in advance,

Peter

veremin
Product Manager
Posts: 16691
Liked: 1394 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Location of BackupSync session info in Veeam DB

Post by veremin » Jan 22, 2019 3:51 pm

Just to double check - are you after getting backup copy job task session? I'm wondering because there is a simpler way to get it. Thanks!

PeterLouwerse
Service Provider
Posts: 4
Liked: never
Joined: Aug 09, 2012 8:06 am
Full Name: Peter Louwerse
Contact:

Re: Location of BackupSync session info in Veeam DB

Post by PeterLouwerse » Jan 22, 2019 4:49 pm

Yup, I'm after the session info for the backup copy job tasks. I tried getting the info using PowerShell only but since not all of our jobs have individual chains per VM, the data I got was "incorrect". I found a post somewhere (on this forum I think) that showed how to get the correct data using the views in the DB. For the backup and replication jobs I now get the correct data.

veremin
Product Manager
Posts: 16691
Liked: 1394 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Location of BackupSync session info in Veeam DB

Post by veremin » Jan 22, 2019 6:36 pm

If so, why not to use the following cmdlet:

Code: Select all

$Job = Get-VBRJob -name "Name of your Backup Copy Job"
$Session = $Job.FindLastSession()
$Session.GetTaskSessions()
It should return information regarding VM task session regardless of the what is selected as a job source.

Thanks!

PeterLouwerse
Service Provider
Posts: 4
Liked: never
Joined: Aug 09, 2012 8:06 am
Full Name: Peter Louwerse
Contact:

Re: Location of BackupSync session info in Veeam DB

Post by PeterLouwerse » Jan 24, 2019 2:31 pm

Will take a look....but it still leaves me wondering where the data is stored in the DB :-)

Thx.

Peter

veremin
Product Manager
Posts: 16691
Liked: 1394 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Location of BackupSync session info in Veeam DB

Post by veremin » Jan 24, 2019 2:53 pm

Typically we don't publish configuration db object structure. Nor do we endorse usage of "creative" workaround (unless when absolutely required - like no alternative exists). Thanks!

Post Reply

Who is online

Users browsing this forum: Baidu [Spider], Majestic-12 [Bot] and 10 guests