PowerShell script exchange
Post Reply
massimiliano.rizzi
Service Provider
Posts: 205
Liked: 26 times
Joined: Jan 24, 2012 7:56 am
Full Name: Massimiliano Rizzi
Contact:

Backup copy job post-script to eject a removable storage

Post by massimiliano.rizzi »

Hello experts,

I am trying to make a post-job script that should:

==================================================

- eject a removable storage media (such as USB hard drives or RDX disks) right after a Backup Copy job finishes successfully

- disable the Backup Copy job right after it finishes in order to avoid the amount of notification emails for a Backup Copy job in the idle state because the repository isn't available since it has already been ejected

==================================================

Veeam Technical Support (Closed Case # 03033055) provided me with a link to the forum with similar problem. One of Veeam engineers advised some modification to the script in order to check that the job was actually doing something before disabling it.

Based om my experience so far with post-job scripts, I have noticed that they are so much more easier to implement with Backup jobs rather than Backup Copy jobs since Backup Copy jobs have a completely different logic. To be honest I didn't have any problems at all when using post-job scripts with Backup job.

I fully understand that Veeam does not support customer defined scripts, so I was wondering if someone has come up with a possible and reliable solution.

I have had some sort of success with the post-job script logic below in order to disable the Backup Copy job right after it finishes, but in many cases I haven’t:

Code: Select all

asnp VeeamPSSNapin
$Job = Get-VBRJob -name "Backup Copy Job 2 giornaliero VM di produzione"
$LastSession = $Job.FindLastSession()
#If (($LastSession.endtime.DayOfYear -eq (Get-date).DayOfYear) –and ($LastSession.State -eq  "Success") -and ((($LastSession.endtime) - ($LastSession.creationtime)).Minutes -ge "10")) {$Job.DisableScheduler()}
If (($LastSession.endtime.DayOfYear -eq (Get-date).DayOfYear) -and ((($LastSession.endtime) - ($LastSession.creationtime)).Minutes -ge "10")) {
Disable-VBRJob -Job $job
}
Any help will be greatly appreciated.

Thanks and Regards,

Massimiliano
Dima P.
Product Manager
Posts: 14396
Liked: 1568 times
Joined: Feb 04, 2013 2:07 pm
Full Name: Dmitry Popov
Location: Prague
Contact:

Re: Backup copy job post-script to eject a removable storage

Post by Dima P. »

Hello Massimiliano.

Looks like the script proposed here is a good way to implement it, take a look at this thread Dismount USB External Drive using powershell. Cheers!
massimiliano.rizzi
Service Provider
Posts: 205
Liked: 26 times
Joined: Jan 24, 2012 7:56 am
Full Name: Massimiliano Rizzi
Contact:

Re: Backup copy job post-script to eject a removable storage

Post by massimiliano.rizzi » 1 person likes this post

Hello Dmitry,

thank you for taking the time to reply to my question.

Unfortunately I'm struggling with the post-job script logic in order to disable the Backup Copy job right after it finishes, while dismounting a removable storage media works just fine.

I was wondering if the post-job script logic proposed above or one or more events written by Veeam Backup & Replication to Microsoft Windows Event Log on the backup server are less error prone and most reliable.

Thanks and Regards,

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

Re: Backup copy job post-script to eject a removable storage

Post by veremin » 1 person likes this post

Can't you just set a script disabling cop job as job post activity? It should get triggered as soon as backup copy enters idle stage (right after processing has been finished). Thanks.
Post Reply

Who is online

Users browsing this forum: No registered users and 14 guests