-
- Veeam ProPartner
- Posts: 156
- Liked: 43 times
- Joined: Oct 28, 2012 6:06 pm
- Full Name: Davide Depaoli
- Location: Santhia' (VC) - Italy
- Contact:
Exit codes of backup job (for email script purpose)
I'm trying to extract job result from logfile (/var/log/veeam/Bakup/JOBNAME) but I'm not able to find nothing (like Job successfull, or job failed), in order to create a script to email the job result.
Is there any string in the log or any other way to know the job status ?
tnx
Davide
Is there any string in the log or any other way to know the job status ?
tnx
Davide
-
- Veeam ProPartner
- Posts: 156
- Liked: 43 times
- Joined: Oct 28, 2012 6:06 pm
- Full Name: Davide Depaoli
- Location: Santhia' (VC) - Italy
- Contact:
Re: Exit codes of backup job (for email script purpose)
Have seen that only failure is logged in Job.log
-
- Product Manager
- Posts: 6551
- Liked: 765 times
- Joined: May 19, 2015 1:46 pm
- Contact:
Re: Exit codes of backup job (for email script purpose)
Hi,
We are going to format logs so they get more informative in future version. For now I can assure you that if there is no "Job has failed" string in Job.log then the backup ended successfully. I assume that you're going to send emails directly from the host, may I ask you what email client you've chosen to use and why?
Thanks
We are going to format logs so they get more informative in future version. For now I can assure you that if there is no "Job has failed" string in Job.log then the backup ended successfully. I assume that you're going to send emails directly from the host, may I ask you what email client you've chosen to use and why?
Thanks
-
- Product Manager
- Posts: 5797
- Liked: 1215 times
- Joined: Jul 15, 2013 11:09 am
- Full Name: Niels Engelen
- Contact:
Re: Exit codes of backup job (for email script purpose)
You can add a script that will send an e-mail with the result on the job (post job script).
Personal blog: https://foonet.be
GitHub: https://github.com/nielsengelen
GitHub: https://github.com/nielsengelen
-
- Product Manager
- Posts: 6551
- Liked: 765 times
- Joined: May 19, 2015 1:46 pm
- Contact:
Re: Exit codes of backup job (for email script purpose)
Currently only pre/post freeze/thaw scripts are available, there is no post-job script option in Beta.
-
- Veeam ProPartner
- Posts: 156
- Liked: 43 times
- Joined: Oct 28, 2012 6:06 pm
- Full Name: Davide Depaoli
- Location: Santhia' (VC) - Italy
- Contact:
Re: Exit codes of backup job (for email script purpose)
PTide wrote:Hi,
We are going to format logs so they get more informative in future version. For now I can assure you that if there is no "Job has failed" string in Job.log then the backup ended successfully. I assume that you're going to send emails directly from the host, may I ask you what email client you've chosen to use and why?
Thanks
I'm just playing with a test centos vm, and I was planning to take out the string from the logfile and pass it to the mail command of linux (mailx)
-
- Veeam ProPartner
- Posts: 156
- Liked: 43 times
- Joined: Oct 28, 2012 6:06 pm
- Full Name: Davide Depaoli
- Location: Santhia' (VC) - Italy
- Contact:
Re: Exit codes of backup job (for email script purpose)
For example:
veeamconfig session list | grep Failed
TestNFS Backup {187c8d92-7bc5-4300-9a6b-03482a544b98} Failed 2016-07-14 11:33 2016-07-14 11:35
formatting in some way the output and pass it to mailx command
veeamconfig session list | grep Failed
TestNFS Backup {187c8d92-7bc5-4300-9a6b-03482a544b98} Failed 2016-07-14 11:33 2016-07-14 11:35
formatting in some way the output and pass it to mailx command
-
- Product Manager
- Posts: 6551
- Liked: 765 times
- Joined: May 19, 2015 1:46 pm
- Contact:
Re: Exit codes of backup job (for email script purpose)
If you'd like to do some advanced text formatting then I recommend you to use sed, cut, and awk utilities. Mailx also accept pipeline input, for example:
awk example:
Code: Select all
veeamconfig session list | grep Failed | mailx -s "Failed jobs" root@localhost
Code: Select all
veeamconfig session list | grep Failed | awk '{print $1,$4,$7,$8}' | mailx -s "Failed jobs" root@localhost
-
- Veeam ProPartner
- Posts: 156
- Liked: 43 times
- Joined: Oct 28, 2012 6:06 pm
- Full Name: Davide Depaoli
- Location: Santhia' (VC) - Italy
- Contact:
Re: Exit codes of backup job (for email script purpose)
I'm trying with grep, because have very very old and rusty memories of shell scripting (my latest script dates back to about 20 years ago !).
My simple script I'm trying now is:
veeamconfig session list | grep UUID > body.txt
veeamconfig session list | grep Failed >> body.txt
cat body.txt | mailx -s "VAL session Failed" my@email.it
My simple script I'm trying now is:
veeamconfig session list | grep UUID > body.txt
veeamconfig session list | grep Failed >> body.txt
cat body.txt | mailx -s "VAL session Failed" my@email.it
-
- VeeaMVP
- Posts: 6166
- Liked: 1971 times
- Joined: Jul 26, 2009 3:39 pm
- Full Name: Luca Dell'Oca
- Location: Varese, Italy
- Contact:
Re: Exit codes of backup job (for email script purpose)
As a lover of one-liners, you can improve your code like this:
No need for a temp txt file
Code: Select all
veeamconfig session list | grep -e UUID -e Failed | mailx -s "VAL session Failed" my@email.it
Luca Dell'Oca
Principal EMEA Cloud Architect @ Veeam Software
@dellock6
https://www.virtualtothecore.com/
vExpert 2011 -> 2022
Veeam VMCE #1
Principal EMEA Cloud Architect @ Veeam Software
@dellock6
https://www.virtualtothecore.com/
vExpert 2011 -> 2022
Veeam VMCE #1
-
- Veeam ProPartner
- Posts: 156
- Liked: 43 times
- Joined: Oct 28, 2012 6:06 pm
- Full Name: Davide Depaoli
- Location: Santhia' (VC) - Italy
- Contact:
Re: Exit codes of backup job (for email script purpose)
Added a $TODAY variable to avoid sending emails with old Failed session
TODAY=$(date +"%Y-%m-%d %H:%M")
veeamconfig session list | grep -e UUID -e Failed | grep $TODAY | mailx -s "VAL session Failed" my@email.it
TODAY=$(date +"%Y-%m-%d %H:%M")
veeamconfig session list | grep -e UUID -e Failed | grep $TODAY | mailx -s "VAL session Failed" my@email.it
-
- Veeam ProPartner
- Posts: 156
- Liked: 43 times
- Joined: Oct 28, 2012 6:06 pm
- Full Name: Davide Depaoli
- Location: Santhia' (VC) - Italy
- Contact:
Re: Exit codes of backup job (for email script purpose)
Right TODAY variable format is without %H:%M.
TODAY=$(date +"%Y-%m-%d")
veeamconfig session list | grep -e UUID -e Failed | grep $TODAY | mailx -s "VAL session Failed" my@email.it
In this way the script is working as espected (by me) and report only today failed sessions.
I've seen my post forwarded to another user requesting email feature. I want royalties or special mention by veeam (I'm joking, of course )
TODAY=$(date +"%Y-%m-%d")
veeamconfig session list | grep -e UUID -e Failed | grep $TODAY | mailx -s "VAL session Failed" my@email.it
In this way the script is working as espected (by me) and report only today failed sessions.
I've seen my post forwarded to another user requesting email feature. I want royalties or special mention by veeam (I'm joking, of course )
-
- Veeam ProPartner
- Posts: 156
- Liked: 43 times
- Joined: Oct 28, 2012 6:06 pm
- Full Name: Davide Depaoli
- Location: Santhia' (VC) - Italy
- Contact:
Re: Exit codes of backup job (for email script purpose)
I have implemented some controls to my script:
#1 - starting the job
#2 - checking and waiting until job is finished
#3 - test the exit result of the job (Failed or Success)
# - 4 send email in both cases, if job is failed or successful.
#1 - starting the job
#2 - checking and waiting until job is finished
#3 - test the exit result of the job (Failed or Success)
# - 4 send email in both cases, if job is failed or successful.
Code: Select all
#!/bin/bash
#
# Script to run Veeam backup and email job status (BackupJob3)
veeamconfig job start --id {ba6434ea-55cc-4529-a9d3-69ec868769e9}
JOBNAME=BackupJob3
export JOBNAME
TODAY=$(date +"%Y-%m-%d")
export TODAY
#VEEAM_PID=`pgrep veeamjobman`
#export VEEAM_PID
until [ -z `pgrep veeamjobman` ]
do
echo "job is running" > /dev/null
done
FAILED=`veeamconfig session list | grep -e Failed | grep $JOBNAME | grep $TODAY`
export FAILED
if [ -z "$FAILED" ]
then
echo "Job $JOBNAME Successfull" | mailx -s "VAL session $JOBNAME Successfull" my@email.com
else
echo "Job $JOBNAME Failed" | mailx -s "VAL session $JOBNAME Failed" my@email.com
fi
Who is online
Users browsing this forum: No registered users and 4 guests