Comprehensive data protection for all workloads
Post Reply
rlehnert
Novice
Posts: 3
Liked: never
Joined: Feb 13, 2014 7:31 am
Full Name: Lehnert Rudolf
Contact:

post job activity only when Veeam backup completed OK?

Post by rlehnert »

Hi!
Searched up + down in the forum but found nothing concerning my problem.

I want to run a "post job activity" (= run the following command) only if the Veeam Backup-job completed with an OK status.
Assume I have a Veeam Backup job defined an afterwards I want to copy the backed up VMs to another disk.
I'd define a "post job activity" with a robocopy, rsync, whatever.
But I'd only want to do the copyin if the Veeam job exited with "OK". I'd not want to copy anything if the Veeam job had errors.
Is there a way to check the exit status of the Veeam job from the afterwards called "post job activity" job?

Hope someone has an idea!
Fanx a lot in advance!

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

Re: post job activity only when Veeam backup completed OK?

Post by veremin »

You can write a script that checks job last result and proceeds to further commands only if the last job session was successful. Then, set this script as a post job activity.

Code: Select all

asnp VeeamPSSnapin
$Job = Get-VBRJob -name "Name of your backup"
if ($job.GetLastResult() -eq "Success")
{
Place your commands here
}
Thanks.
rlehnert
Novice
Posts: 3
Liked: never
Joined: Feb 13, 2014 7:31 am
Full Name: Lehnert Rudolf
Contact:

Re: post job activity only when Veeam backup completed OK?

Post by rlehnert »

Hi!
Thanks for the fast reply!

Your code doesn't look to me like a Windows "CMD" code.....
What "language" is it?
Could this be achieved with "DOS" (.cmd) code, too?

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

Re: post job activity only when Veeam backup completed OK?

Post by veremin »

Sorry, I should have been more clearer - it's nothing but a PowerShell script that uses our PS snapin.

If you're after running executables in PowerShell, kindly, see this TechNet article; should give you some hints.

Thanks.
rlehnert
Novice
Posts: 3
Liked: never
Joined: Feb 13, 2014 7:31 am
Full Name: Lehnert Rudolf
Contact:

Re: post job activity only when Veeam backup completed OK?

Post by rlehnert »

Fanx!
I'll read this article and try to follow your hints!
Bye
veremin
Product Manager
Posts: 20270
Liked: 2252 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: post job activity only when Veeam backup completed OK?

Post by veremin » 1 person likes this post

You're welcome. Should any other questions arise, don't hesitate to let us know.
ocky72
Influencer
Posts: 16
Liked: 2 times
Joined: Nov 21, 2012 4:15 pm
Full Name: Andy Blackman
Contact:

[MERGED] Delete files on Successful Backup

Post by ocky72 »

Hi

We're in the process of removing the final remnants of our legacy backup system (after a few years of using Veeam).

On our legacy backup system when a user leaves we archive their mailboxes off to a PST and the old backup system backs them up to a reference backup and deletes them on a successful backup.

So, looking to implement the same functionality, does the "Run the following script after the job" only run after a successful backup, or does it run even if the backup fails?

If it runs regardless, is there any way to run something to delete files after a successful backup?

Thanks

Andy
foggy
Veeam Software
Posts: 21069
Liked: 2115 times
Joined: Jul 11, 2011 10:22 am
Full Name: Alexander Fogelson
Contact:

Re: post job activity only when Veeam backup completed OK?

Post by foggy »

Andy, post-job activity command is executed regardless of the job status, however you can use PowerShell script to check the status and then execute the required action. Please see above for details.
ocky72
Influencer
Posts: 16
Liked: 2 times
Joined: Nov 21, 2012 4:15 pm
Full Name: Andy Blackman
Contact:

Re: post job activity only when Veeam backup completed OK?

Post by ocky72 »

Excellent - thanks. I didn't find that thread when I searched.
foggy
Veeam Software
Posts: 21069
Liked: 2115 times
Joined: Jul 11, 2011 10:22 am
Full Name: Alexander Fogelson
Contact:

Re: post job activity only when Veeam backup completed OK?

Post by foggy »

Thanks for using search, anyway. ;)
Post Reply

Who is online

Users browsing this forum: kyle.shuberg, ybarrap2003 and 171 guests