Availability for the Always-On Enterprise
mzamesnik
Novice
Posts: 7
Liked: 1 time
Joined: Jun 25, 2012 5:44 pm
Full Name: Mike Zamesnik
Contact:

Variables for pre/post job scripts

Post by mzamesnik » Jan 14, 2015 6:19 pm

Are there a list of valid variables that can be used as parameters in the pre/post job scripts? I am particularly interested in whether or not the job name can be passed as an argument to the script i want to run before the job.

v.Eremin
Veeam Software
Posts: 15077
Liked: 1133 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Variables for pre/post job scripts

Post by v.Eremin » Jan 15, 2015 9:38 am

You mean you want to pass something like %Name? If so, it's not possible, and you should get a job name inside a script. Thanks.

mzamesnik
Novice
Posts: 7
Liked: 1 time
Joined: Jun 25, 2012 5:44 pm
Full Name: Mike Zamesnik
Contact:

Re: Variables for pre/post job scripts

Post by mzamesnik » Mar 24, 2015 6:13 pm

Yes, that is what I had hoped to do. This way I could build a single script that would use the job name as a variable, if I wanted to affect that particular job - as opposed to creating a unique script for each job. It's not a deal breaker. Just a convenience I had hoped existed. I was able to go about it a different way. Thanks for your reply. Sorry for my late reply.

Gostev
Veeam Software
Posts: 22808
Liked: 2801 times
Joined: Jan 01, 2006 1:01 am
Location: Baar, Switzerland
Contact:

Re: Variables for pre/post job scripts

Post by Gostev » Mar 24, 2015 7:14 pm

It's a good idea to add.

tsightler
Veeam Software
Posts: 5167
Liked: 2057 times
Joined: Jun 05, 2009 12:57 pm
Full Name: Tom Sightler
Contact:

Re: Variables for pre/post job scripts

Post by tsightler » Mar 25, 2015 1:47 am 2 people like this post

Wow, interestingly I just had this very same requirement. I'm curious how you solved it. I came up with the following hack that I just posted on our internal forums yesterday:

Code: Select all

$parentpid = (Get-WmiObject Win32_Process -Filter "processid='$pid'").parentprocessid.ToString()
$parentcmd = (Get-WmiObject Win32_Process -Filter "processid='$parentpid'").CommandLine
$job = Get-VBRJob | ?{$parentcmd -like "*"+$_.Id.ToString()+"*"}
$session = Get-VBRBackupSession | ?{($_.OrigJobName -eq $job.Name) -and ($parentcmd -like "*"+$_.Id.ToString()+"*")}
This looks up the parent process ID of the Powershell session, which in the case of pre/post-scripts is the Veeam.Backup.Manager.exe that controls the job session. The script then grabs the command line used to start said manager process process which as it happens includes the Veeam job and session UUID. This typically looks something like this:

Code: Select all

"C:\Program Files\Veeam\Backup and Replication\Backup\Veeam.Backup.Manager.exe" "startbackupjob" "owner=[vbsvc]" "Normal" "a6782dae-5ebe-4aab-9cb3-3a75827dff22" "a432e43e-b17c-4778-b9d2-e8d6519526ea"
It then does a crude match on these UUIDs to find the actual job and session PS objects and I'm good to go with all of the information I need even with nothing passed in. I should improve the match code as right now it could potentially get the wrong job if somehow a session ID was exactly the same as a job ID or vice-versa. This seems pretty much impossible to occur in the real world but when I have a few minutes I'll add a little logic to address that.

Still, I'd love to hear how you attacked the problem, perhaps it was a better method.

v.Eremin
Veeam Software
Posts: 15077
Liked: 1133 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Variables for pre/post job scripts

Post by v.Eremin » Mar 25, 2015 9:21 am

mzamesnik wrote:Yes, that is what I had hoped to do. This way I could build a single script that would use the job name as a variable, if I wanted to affect that particular job.
So, the %JobName variable for pre/post-job scripts and %VMname for pre-freeze/post-thaw VM scripts should be enough, right? As having those variables would allow to catch whatever specific information you want to. Thanks.

heydonms
Novice
Posts: 3
Liked: never
Joined: Aug 12, 2013 12:39 am
Full Name: Michael Heydon
Contact:

Re: Variables for pre/post job scripts

Post by heydonms » Aug 17, 2015 1:21 am

v.Eremin wrote:So, the %JobName variable for pre/post-job scripts and %VMname for pre-freeze/post-thaw VM scripts should be enough, right?
For pre/post-job scripts I would add:

Whether the backup run will be/was full/incremental

and for post-job scripts

Whether the backup completed with success/warning/partial/failed/etc.

v.Eremin
Veeam Software
Posts: 15077
Liked: 1133 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Variables for pre/post job scripts

Post by v.Eremin » Aug 17, 2015 8:50 am

Got it. Though, having the described variables ($VMName and $Jobname) it would be pretty simple to get that information inside the code itself.

ekisner
Expert
Posts: 177
Liked: 33 times
Joined: Jul 26, 2012 8:04 pm
Full Name: Erik Kisner
Contact:

Re: Variables for pre/post job scripts

Post by ekisner » Nov 16, 2015 8:06 pm

Just wanted to post my support for this, if it has not yet been implemented.

In our case, we're getting service management software finally, which I would like to leverage via APIs. At the end of a job, if the job failed, log a ticket with the SM with a specific name (checking for existing tickets first to ensure that the system doesn't get spammed). The SM software uses soap so I can talk to it with powershell easily.

v.Eremin
Veeam Software
Posts: 15077
Liked: 1133 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Variables for pre/post job scripts

Post by v.Eremin » Nov 17, 2015 9:33 am

The said functionality has not been implemented yet. But it's still on our radar. Thanks.

fgw
Enthusiast
Posts: 66
Liked: 2 times
Joined: Jun 11, 2009 8:39 pm
Full Name: Franz Glatzer
Contact:

Re: Variables for pre/post job scripts

Post by fgw » Feb 07, 2016 12:30 pm

guys i searched the forums and the internet and was not able to find any answer to this!

question remains: is this still not implemented?

come on this is not rocket science! it should be fairly easy for veam devs to implement passing ALL AVAILABLE parameters - and im not talking about jobnnames only - im talking about jobname, retry count, max retries configured, last result, whatever ...

actually retry count and max retries configured seems of most importance to me. i does not make any sense to start the post processing action as long as the job might retry to run. the script needs to know if this was the last retry or not in order to start processing its tasks e.g. start copy the backup somewhere!

pls dont get me wrong! this is not meant to be offensive in any way! its just soo simple and i suppose of almost no work for veeam but of so much help for us admins out there! so pls implement this. this is already done for post job mails! pls implement this for post job scripts too!

if i missed it and its already implemented, pls point me to the right location where this is documented! i simply was not able to find it.

THANKS

Gostev
Veeam Software
Posts: 22808
Liked: 2801 times
Joined: Jan 01, 2006 1:01 am
Location: Baar, Switzerland
Contact:

Re: Variables for pre/post job scripts

Post by Gostev » Feb 07, 2016 1:11 pm

Hi, Franz. We prioritize [hundreds] of pending feature requests based on demand and as you can see, there were too few requests for this functionality for now. Thanks!

v.Eremin
Veeam Software
Posts: 15077
Liked: 1133 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Variables for pre/post job scripts

Post by v.Eremin » Feb 08, 2016 8:50 am

it should be fairly easy for veam devs to implement passing ALL AVAILABLE parameters - and im not talking about jobnnames only - im talking about jobname, retry count, max retries configured, last result, whatever ...
I still believe that having job name as a variable should be enough, since with this parameter at hand it will be fairly easy to get all other properties via our PowerShell snap-in.

And for now you can stick to the workaround coined by Tom, until we get that functionality implemented.

Thanks.

jonheese
Lurker
Posts: 1
Liked: never
Joined: Feb 26, 2016 5:31 pm
Full Name: Jon Heese
Contact:

Re: Variables for pre/post job scripts

Post by jonheese » Feb 26, 2016 5:33 pm

Gostev wrote:Hi, Franz. We prioritize [hundreds] of pending feature requests based on demand and as you can see, there were too few requests for this functionality for now. Thanks!
Where do we need to go to vote for/request this feature? Thanks.

fgw
Enthusiast
Posts: 66
Liked: 2 times
Joined: Jun 11, 2009 8:39 pm
Full Name: Franz Glatzer
Contact:

Re: Variables for pre/post job scripts

Post by fgw » Feb 28, 2016 10:01 pm

the reason i need this is to decide if certain actions in this script needs to be performed based on job status!

as stated earlier, it doesn't make any sense to trigger copy of the backup file to second location when the job failed and probably will start a retry in a couple of minutes ...

thus i would like to see "Last Result", "Retry Count", and "Retries performed".

that way its easy to figure out if this was already the last retry: "Retry Count" == "Retries performed"

or there are some more retries pending: "Retry Count" > "Retries performed"

and of course "Last Result" as it does also make no sense to copy failed backups.

well, it might be sufficient to just have "Last Result" passed, as if the job was successful there won't be any more retries anyway ...

regarding the way to get jobname within the script as posted earlier:

as scripts are configured for every job individually, it can be done pretty easy by passing the name of the job as parameter to the script. of course this wont help in getting UUID if thats needed also!

to get the nameof the vm within the pre/post thaw scripts shouldn't be much of a problem either. suppose u can use %COMPUTERNAME% on windows and probably $hostname on unix?

reason for coming back here:
actually i thought i can come around the use of post scripts to copy backupfiles to a secondary location. as nice as "backup copy" and "file copy" jobs are, they perform very bad in my environment. they are nicely integrated and offer sweet features but my problem is performance! did some testing and figured out copying the backupfiles between windows server using copy is about 2 times faster than copying the very same data through veeam! and this scales nicely with network bandwidth also.

have no idea why "backup copy" and "file copy" is so slow here, may be i have setup something odd, but i doubt as setting this up is very straight forward!

so i'm back to the start again and consider using scripts for this task. and that's where my problem popped up again ...

ps. will open a thread tomorrow with the figures regarding transfer speeds i observed . late here already, too lazy now!

Post Reply

Who is online

Users browsing this forum: No registered users and 29 guests