Standalone backup agent for Microsoft Windows servers and workstations (formerly Veeam Endpoint Backup FREE)
Post Reply
dra
Novice
Posts: 6
Liked: 1 time
Joined: Oct 15, 2010 5:16 am
Full Name: Daniel Abels

Checking status of last backup from command line?

Post by dra »

Hi,

I've done a search (via Google), but I can't find anything on this topic (see subject line), for the Windows Agent anyway.

What I'm trying to do, is find status of the last backup, preferably though a command.

With the Linux Agent, I can run:

veeamconfig session list | tail -2 | grep Success

But I don't see anything equivalent like this with the Veeam Agent for Windows.

I'm running 2.2.0.589.

I suppose one could examine log files... But that's more work.

Thanks in advance,

Daniel
MichaelCade
Veeam Software
Posts: 314
Liked: 74 times
Joined: Mar 23, 2015 11:55 am
Full Name: Michael Cade
Location: Cambridge, United Kingdom
Contact:

Re: Checking status of last backup from command line?

Post by MichaelCade »

Hey Daniel,

Check out the last section of the user guide here - https://helpcenter.veeam.com/docs/agent ... tml?ver=21

This may only be if the job is created or started from the CLI also but this should give you a response.
Regards,

Michael Cade
Global Technologist
Veeam Software
Email: Michael.Cade@Veeam.com
Twitter: @MichaelCade1
Dima P.
Product Manager
Posts: 14417
Liked: 1576 times
Joined: Feb 04, 2013 2:07 pm
Full Name: Dmitry Popov
Location: Prague
Contact:

Re: Checking status of last backup from command line?

Post by Dima P. »

Hello Daniel,
find status of the last backup, preferably though a command
Would Windows events work for your case? Check this article to get the list of all available events generated by Veeam Agent for Windows and let us know if that works for you. Cheers!
dra
Novice
Posts: 6
Liked: 1 time
Joined: Oct 15, 2010 5:16 am
Full Name: Daniel Abels

Re: Checking status of last backup from command line?

Post by dra »

Thanks for the tips guys.

I think I'll look into the Event log angle first, that seems like a good starting point.

Daniel
dra
Novice
Posts: 6
Liked: 1 time
Joined: Oct 15, 2010 5:16 am
Full Name: Daniel Abels

Re: Checking status of last backup from command line?

Post by dra » 1 person likes this post

From the command line, I now do:
wevtutil qe "Veeam Agent" /q:"*[System[(EventID=190) and TimeCreated[timediff(@SystemTime) <= 604800000]]]" | findstr /n ^^ | findstr "^[1]:" | findstr "Success"
(Yeah, you could/should use Powershell, but this works...)

This returns the events from the last seven days, relating to the backup status. Then through the magic of find, I return the first line (i.e. last backup) and check if it was a success.

From there, I check the errorlevel environment variable to see if there is a match or not.

This will do nicely as a Nagios check. :D

Thanks guys!
spiritie
Service Provider
Posts: 191
Liked: 40 times
Joined: Mar 01, 2016 10:16 am
Full Name: Gert
Location: Denmark
Contact:

Re: Checking status of last backup from command line?

Post by spiritie »

For anyone else finding this thread through Google in the future, I've created a PowerShell version of this:

- Checks for latest event ID = 190
- Checks the severity of the ID
- Checks 24 hours back
- For the success there is also a extra checks in details of the event ID to check for "finished with Success"
- Everything else will be a failure
- Also reports if it did not find a 190 within 24 hours

Code: Select all

# PowerShell script to check the Veeam Agent log for the latest event ID 190

$logName = "Veeam Agent"
$eventId = 190
$startTime = (Get-Date).AddHours(-24) # Get the date-time 24 hours ago

# Get the latest event with ID 190 from the Veeam Agent log within the last 24 hours
$latestEvent = Get-WinEvent -FilterHashtable @{
    LogName   = $logName
    ID        = $eventId
    StartTime = $startTime
} -MaxEvents 1 -ErrorAction SilentlyContinue

if ($latestEvent) {
    # Remove newlines from the message
    $message = $latestEvent.Message -replace "\r\n", " " -replace "\r", " " -replace "\n", " "
    
    # Get the date and time when the event was created
    $eventTime = $latestEvent.TimeCreated.ToString("dd-MM-yyyy HH:mm")
    
    # Check the severity level and description of the event
    switch ($latestEvent.LevelDisplayName) {
        'Information' {
            # Check if the description matches "finished with Success"
            if ($message -match "finished with Success") {
                Write-Host "Success" "|" $eventTime "|" $message
            }
            else {
                Write-Host "Failed" "|" $eventTime "|" $message
            }
        }
        'Warning' { Write-Host "Failed" "|" $eventTime "|" $message }
        'Error' { Write-Host "Failed" "|" $eventTime "|" $message }
        Default { Write-Host "Failed" "|" $eventTime "|" $message }
    }
}
else {
    Write-Host "No event found with ID $eventId in the last 24 hours."
}
Post Reply

Who is online

Users browsing this forum: No registered users and 21 guests