Need script to check if a tape job is running please

PowerShell script exchange

Need script to check if a tape job is running please

Veeam Logoby namiko78 » Mon Sep 14, 2015 5:01 pm

I'd like to run a script on my main backup jobs, that check to see if a tape job is running, and if so, wait for that to complete. Does anyone know of any that already exists out there?

Thank you!
namiko78
Expert
 
Posts: 110
Liked: 4 times
Joined: Thu Mar 03, 2011 1:49 pm
Full Name: Steven Stirling

Re: Need script to check if a tape job is running please

Veeam Logoby PTide » Mon Sep 14, 2015 5:14 pm

Hi,

Please check this thread. You'll need to replace Get-VBRJob with Get-VBRTapeJob and $Job.GetLastState() -eq "Working" with $J.LastState -eq "Working"

Thank you.
PTide
Veeam Software
 
Posts: 3019
Liked: 246 times
Joined: Tue May 19, 2015 1:46 pm

Re: Need script to check if a tape job is running please

Veeam Logoby v.Eremin » Tue Sep 15, 2015 12:40 pm

I didn't have a time to test it, but I think the following script should work fine:

Code: Select all
asnp VeeamPSSnapin
$TapeJob = Get-VBRTapeJob -name "Name of Tape Job"
if ($TapeJob.LastState -ne "Working"){exit}
else
{
    do
    {   
        Start-sleep -s 300 #5 minute waiting interval
        $TapeJob = Get-VBRTapeJob -name "Name of Tape Job"
    }
}while ($TapeJob.LastState -ne "Working")


Thanks.
v.Eremin
Veeam Software
 
Posts: 13266
Liked: 968 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin

Re: Need script to check if a tape job is running please

Veeam Logoby namiko78 » Tue Sep 15, 2015 1:09 pm

Thanks. I managed to manually install the powershell plugin, launched it from the top left menu, but there seems to be no get-vbrtapejob command.... do i have an old version? i'm running 8.0.0.2021 but i installed the powershell plugiun from the origional version before the patch.

Just noticed that when i launch the powershell from the left menu, i get a "no snapins have been registered for windows poershell version 4"
namiko78
Expert
 
Posts: 110
Liked: 4 times
Joined: Thu Mar 03, 2011 1:49 pm
Full Name: Steven Stirling

Re: Need script to check if a tape job is running please

Veeam Logoby v.Eremin » Tue Sep 15, 2015 2:05 pm

What if you try to start a PowerShell outside of backup console and check whether VeeamPSSnapin has been registered successfully, using "Get-PSSnapin" (to be sure run PS as administrator)?
v.Eremin
Veeam Software
 
Posts: 13266
Liked: 968 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin

Re: Need script to check if a tape job is running please

Veeam Logoby namiko78 » Tue Sep 15, 2015 3:00 pm

get-pssnapin just gives me the 1, and it's the core one. nothing else.
namiko78
Expert
 
Posts: 110
Liked: 4 times
Joined: Thu Mar 03, 2011 1:49 pm
Full Name: Steven Stirling

Re: Need script to check if a tape job is running please

Veeam Logoby v.Eremin » Tue Sep 15, 2015 5:38 pm

Can you try to re-install snap-in either manually, using Install-VeeamToolkit.ps1 script in "C:\Program Files\Veeam\Backup and Replication", or automatically through general setup wizard and see whether it helps?
v.Eremin
Veeam Software
 
Posts: 13266
Liked: 968 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin

Re: Need script to check if a tape job is running please

Veeam Logoby namiko78 » Tue Sep 15, 2015 7:24 pm

Tried both, didn't work :( The wizard didn't actually get very far because i have jobs running and it told me to disable them.
namiko78
Expert
 
Posts: 110
Liked: 4 times
Joined: Thu Mar 03, 2011 1:49 pm
Full Name: Steven Stirling

Re: Need script to check if a tape job is running please

Veeam Logoby v.Eremin » Wed Sep 16, 2015 10:59 am

Let's wait till there is a time window without running jobs and re-install snap-in at that time. Thanks.
v.Eremin
Veeam Software
 
Posts: 13266
Liked: 968 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin

[MERGED] Let the Backup Job wait on an running Tape Job

Veeam Logoby WinstonWolf » Mon May 30, 2016 6:19 pm

Hello ,

I need an Script who lets the Backup Job Waits when an Tape Job for this Files is running .

I have at the End of the Month an "big" Tape Job who Backups 30 Hours from Monday Morning at 03.00 . But on Monday Evening at 7 PM the Backup to Disk Job starts and when Merging begins the Backup To Disk Job Ends the Tape Job .

What i want is an Script who lets the backup to Disk Job waits till the "big" Backup to Tape Job is finished . It is ok when on Monday Evening no Backup to Disk Job runs .

Thanks
Michael
WinstonWolf
Expert
 
Posts: 181
Liked: 4 times
Joined: Thu Jan 06, 2011 8:33 am

Re: Need script to check if a tape job is running please

Veeam Logoby PTide » Tue May 31, 2016 4:26 pm

Please check the script Vladimir has provided and feel free to request an assistance.

Thank you.
PTide
Veeam Software
 
Posts: 3019
Liked: 246 times
Joined: Tue May 19, 2015 1:46 pm

Re: Need script to check if a tape job is running please

Veeam Logoby WinstonWolf » Wed Jun 01, 2016 4:39 am

Hello again ,

Im totally new on Veeam Scripting . What i need for Scripting from Veeam Side ?
How can i insert an Script in Veeam ?

Vladimir , How can Look the Script when i want to prevent an Backup to Disk Job to start when an Tape Job runs at this Time ?

Thanks for Help .

Michael
WinstonWolf
Expert
 
Posts: 181
Liked: 4 times
Joined: Thu Jan 06, 2011 8:33 am

Re: Need script to check if a tape job is running please

Veeam Logoby PTide » Wed Jun 01, 2016 10:53 am

What i need for Scripting from Veeam Side ?
How can i insert an Script in Veeam ?
You need to specify .ps1 file containing the script in Advanced settings of your job so that the script starts before the job.

How can Look the Script when i want to prevent an Backup to Disk Job to start when an Tape Job runs at this Time ?
This part of the script should prevent backup job from starting until tape job is finished:

Code: Select all
if ($TapeJob.LastState -ne "Working"){exit}
else
{
    do
    {   
        Start-sleep -s 300 #5 minute waiting interval
        $TapeJob = Get-VBRTapeJob -name "Name of Tape Job"
    }
}while ($TapeJob.LastState -ne "Working")


Thanks
PTide
Veeam Software
 
Posts: 3019
Liked: 246 times
Joined: Tue May 19, 2015 1:46 pm

Re: Need script to check if a tape job is running please

Veeam Logoby v.Eremin » Thu Jun 02, 2016 10:24 am

And don't forget to add our PS snap-in in the beginning of the script, so that PowerShell has access to VB&R related commandlets.

Code: Select all
Asnp VeeamPSSnapin


Thanks.
v.Eremin
Veeam Software
 
Posts: 13266
Liked: 968 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin

Re: Need script to check if a tape job is running please

Veeam Logoby WinstonWolf » Thu Jun 02, 2016 11:13 am

Should i placed the script in the Tape Job Advanced Settings or in the Backup Job Advanced Settings ?
WinstonWolf
Expert
 
Posts: 181
Liked: 4 times
Joined: Thu Jan 06, 2011 8:33 am

Next

Return to PowerShell



Who is online

Users browsing this forum: No registered users and 6 guests