0% found this document useful (0 votes)
139 views15 pages

veeam backup powershell

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
139 views15 pages

veeam backup powershell

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 15

R&D Forums

Your direct line to Veeam R&D. Not a support forum!

REGISTER LOGIN

Main ‹ Products ‹ Veeam Backup & Replication ‹ PowerShell

Question - Backup Job check powershell for Last 24 hours


16 posts • Page 1 of 1
POST REPLY
3. By the way, the backup job of Agent (Windows and Linux) is not output with the above
PowerShell. and I would like to display the status of the Agent job as in PowerShell for
VMware Backup.

4. How can I check the status (success/failure) of VM and physical machine full backup
jobs?

Re: Question - Backup Job check powershell oleg.feoktistov


Veeam Software
for Last 24 hours
by oleg.feoktistov » Mar 19, 2021 11:15 am Posts: 1995
Liked: 659 times
Joined: Sep 25, 2019 10:32 am
Hi, Full Name: Oleg Feoktistov
Contact:

So, let me recap. The main points are two:

1. Get all backup job sessions ran for the last 24 hours. Datetime class has another
method for that. Since you already use AddDays(), I guess you can easily figure out how
it's called for hours.

2. Get agent backup job sessions. Use Get-VBRComputerBackupJobSessions cmdlet for


that.

Thanks,
Oleg

Re: Question - Backup Job check powershell jbyoon


Novice
for Last 24 hours
by jbyoon » Mar 21, 2021 12:47 am Posts: 6
Liked: never
Joined: Feb 06, 2020 12:07 pm
Thanks, oleg.feoktistov !! Full Name: YOON JOO BYOUNG
Contact:

Thanks to you, I made a PowerShell to check the backup status of the physical server.

CODE: SELECT ALL

foreach ($PBackup_job in (Get-VBRComputerBackupJob | Select Name)) {


$PBackup_job_name = $PBackup_job.Name
Get-VBRComputerBackupJobSession -Name $PBackup_job_name | Where-Object { $_.CreationTime -gt (
}

But, in the
$_.CreationTime -gt (Get-Date).AddDays(-1)

part, the result value one day before I want is not displayed, but the contents of the entire
date are displayed.

This option works without any problems in below..

CODE: SELECT ALL

Get-VBRBackupSession | ?{$_.CreationTime -ge (Get-Date).AddDays(-1)} | Select JobName, JobType, Creati

OutPut:
JobName JobType CreationTime EndTime Result State BackupSize
------- ------- ------------ ------- ------ ----- ----------
VM_Job Backup 3/21/2021 8:17:49 AM 3/21/2021 8:41:59 AM Warning Stopped 18063425536

Anyone ask help me.


Re: Question - Backup Job check powershell oleg.feoktistov
Veeam Software
for Last 24 hours
Posts: 1995
by oleg.feoktistov » Mar 21, 2021 7:51 am
Liked: 659 times
Joined: Sep 25, 2019 10:32 am
Hi, Full Name: Oleg Feoktistov
Contact:

the result value one day before I want is not displayed, but the contents of the entire date
are displayed.

Sorry, I'm not sure what you mean by that.

Try using AddHours() method on Get-Date, looks like it fits more in your case.

Thanks,
Oleg

Re: Question - Backup Job check powershell jbyoon


Novice
for Last 24 hours
by jbyoon » Mar 21, 2021 9:04 am Posts: 6
Liked: never
Joined: Feb 06, 2020 12:07 pm
thank you for the reply. Full Name: YOON JOO BYOUNG
Contact:

I've tried running 2 powershells to check the status of backup jobs that have been running
for 24 hours from the current time.

1. Where-Object { $_.CreationTime -ge (Get-Date).AddDays(-1)}


2. Where-Object { $_.CreationTime -ge (Get-Date).AddHours(-1)}
- AddHours(-1) ~ AddHours(-4) = Not OutPut
- AddHours(-5) ~ AddHours(-6) ..... = All DATA OutPut
I only want to outputs a list of backup jobs within 24 hours. By the way, the above
PowerShell command outputs a list of backup jobs for all periods.
Which command should I apply to get the result I want?

Re: Question - Backup Job check powershell morciodm


Novice
for Last 24 hours
Posts: 9
by morciodm » Mar 22, 2021 1:08 pm
Liked: 1 time
Are there fields specific to NAS File Share backups? these are not being reflected in my Joined: Sep 04, 2018 3:03 pm
Veeam backup daily report? its only VM's Full Name: debra morcio
Contact:

Re: Question - Backup Job check powershell oleg.feoktistov


Veeam Software
for Last 24 hours
by oleg.feoktistov » Mar 22, 2021 2:47 pm 1 person likes this post Posts: 1995
Liked: 659 times
Joined: Sep 25, 2019 10:32 am
@jbyoon, Full Name: Oleg Feoktistov
Contact:

For some reason, the output of Get-VBRComputerBackupJobSession cannot be filtered and


sorted directly.
Try the approach below:

CODE: SELECT ALL

$date = (Get-Date).AddHours(-24)
$sessions = Get-VBRComputerBackupJobSession
$sessions | where {$_.CreationTime -ge $date} | sort CreationTime | Format-Table

Thanks,
Oleg

Re: Question - Backup Job check powershell oleg.feoktistov


Veeam Software
for Last 24 hours
by oleg.feoktistov » Mar 22, 2021 2:48 pm Posts: 1995
Liked: 659 times
Joined: Sep 25, 2019 10:32 am
@morciod, Full Name: Oleg Feoktistov
Contact:

Could you, please, describe which specific fields do you mean?

Thanks,
Oleg

Re: Question - Backup Job check powershell jbyoon


Novice
for Last 24 hours
by jbyoon » Mar 23, 2021 9:54 am Posts: 6
Liked: never
Joined: Feb 06, 2020 12:07 pm
@oleg.feoktistov Full Name: YOON JOO BYOUNG
You are really great !! Contact:
Thanks for giving me tremendous help.

Thanks to your help, I created the final PowerShell script like the one below.

CODE: SELECT ALL

$date = (Get-Date).AddHours(-24)
$sessions = Get-VBRComputerBackupJobSession
foreach ($PBackup_job in (Get-VBRComputerBackupJob | Select Name)) {
$PBackup_job_name = $PBackup_job.Name
write "------------ Physical Server Backup Job Name : $PBackup_job_name ------------"
$sessions | where {$_.CreationTime -ge $date} | sort CreationTime | Select CreationTime, endti
}
Re: Question - Backup Job check powershell jbyoon
Novice
for Last 24 hours
by jbyoon » Mar 23, 2021 10:26 am Posts: 6
Liked: never
Joined: Feb 06, 2020 12:07 pm
I created a PowerShell that outputs the status of two types of backup jobs(VM and physical Full Name: YOON JOO BYOUNG
server) within 24 hours. Contact:
Thanks to everyone who helped.

CODE: SELECT ALL

Add-PSSnapin Veeampssnapin
$date = (Get-Date).AddHours(-24)
$VMsessions = Get-VBRBackupSession
$VMsessions | where {$_.CreationTime -ge $date} |Select @{Name="Type";Expression={"VM"}},@{Name="JobN

$PMsessions = Get-VBRComputerBackupJobSession
foreach ($PBackup_job in (Get-VBRComputerBackupJob | Select Name)) {
$PBackup_job_name = $PBackup_job.Name
$PMsessions | where {$_.CreationTime -ge $date} | sort CreationTime | Select @{Name="Type";Exp
}
Re: Question - Backup Job check powershell Rajesh1210
Influencer
for Last 24 hours
Posts: 12
by Rajesh1210 » Apr 20, 2022 1:41 pm
Liked: never
Joined: Feb 22, 2021 3:31 pm
Hi Oleg, Full Name: Rajesh TK
Contact:

How to list the session for a specific creation time. I am trying the below, but it is not
working.

CODE: SELECT ALL

$session | where {$_.CreationTime -eq 4/16/2022}

oleg.feoktistov wrote: ↑ Mar 22, 2021 2:47 pm


@jbyoon,

For some reason, the output of Get-VBRComputerBackupJobSession cannot be filtered and


sorted directly.
Try the approach below:

CODE: SELECT ALL

$date = (Get-Date).AddHours(-24)
$sessions = Get-VBRComputerBackupJobSession
$sessions | where {$_.CreationTime -ge $date} | sort CreationTime | Format-Table

Thanks,
Oleg
Re: Question - Backup Job check powershell rennerstefan
Veeam Software
for Last 24 hours
Posts: 680
by rennerstefan » Apr 20, 2022 2:00 pm
Liked: 149 times
Joined: Jan 22, 2015 2:39 pm
One way would be: Full Name: Stefan Renner
Location: Germany
Contact:
CODE: SELECT ALL

$sessions | where {$_.CreationTime.day -eq "20" -and $_.CreationTime.month -eq "4" -and $_.CreationTi

Stefan Renner

Veeam PMA

Re: Question - Backup Job check powershell oleg.feoktistov


Veeam Software
for Last 24 hours
by oleg.feoktistov » Apr 20, 2022 2:20 pm Posts: 1995
Liked: 659 times
Joined: Sep 25, 2019 10:32 am
HI Rajesh, Full Name: Oleg Feoktistov
Contact:

It is not working because you are trying to filter CreationTime of datetime type by a string
value. There is no type conversion happenning in this case. Adding to the way Stefan
mentioned, another one would be to parse a date from a string and then use it for
filtering:

CODE: SELECT ALL

$date = [Datetime]::Parse('4/16/2022')
$sessions | where {$_.CreationTime.Date -eq $date}

In this case make sure to filter by CreationTime.Date, not just CreationTime. Otherwise
hours/minutes/seconds in $date won't be ignored, and you will likely receive no results
unless some sessions were started precisely at a default time written to $date (12:00:00
AM).

Thanks,
Oleg

Re: Question - Backup Job check powershell Rajesh1210


Influencer
for Last 24 hours
by Rajesh1210 » Apr 25, 2022 12:55 pm Posts: 12
Liked: never
Joined: Feb 22, 2021 3:31 pm
Hi Oleg, Full Name: Rajesh TK
Contact:

Thanks for the response!

I used the above suggestion but it did not filter out anything. Here is my code,

CODE: SELECT ALL

$job = Get-VBRJob -Name VMC2-PRDCPY-WIN08-GRP01


$session = Get-VBRBackupSession | Where {$_.jobId -eq $job.Id.Guid}
$date = [datetime]::Parse('4/22/2022')
$session | where {$_.CreationTime.Date -eq $date}

Not sure what is missing. Could you please help with this?

Re: Question - Backup Job check powershell oleg.feoktistov


Veeam Software
for Last 24 hours
by oleg.feoktistov » Apr 25, 2022 1:09 pm Posts: 1995
Liked: 659 times
Joined: Sep 25, 2019 10:32 am
Hi Rajesh, Full Name: Oleg Feoktistov
Contact:

Do you mean that it didn't reflect anything or it reflected many more irrelevant sessions?
If it's the first scenario, it would likely mean that it is either something wrong on the steps
of getting job and sessions or no session ran on that date. In this case I'd advise to check
if $job and $session variables hold any values. If they do, please double check if any
session ran on that day for the mentioned job.

Thanks,
Oleg
Rajesh1210
Re: Question - Backup Job check powershell Influencer
for Last 24 hours
Posts: 12
by Rajesh1210 » Apr 26, 2022 12:05 pm Liked: never
Joined: Feb 22, 2021 3:31 pm
Hi Oleg, Full Name: Rajesh TK
Contact:

$job and $session had values in it but not for the date I was querying for. I re-ran them to
populate again. I am able to get what I looked for. Thanks a lot for the help!

16 posts • Page 1 of 1
POST REPLY

Return to “PowerShell”

WHO IS ONLINE
Users browsing this forum: No registered users and 9 guests

MAIN CONTACT US THE TEAM MEMBERS DELETE COOKIES ALL TIMES ARE UTC

DISCLAIMER: All feature and release plans are subject to change without notice.

Powered by phpBB® Forum Software © phpBB Limited


Privacy | Terms | Cookie Settings

You might also like