Script to Check Working status at remote site

PowerShell script exchange

Script to Check Working status at remote site

Veeam Logoby getzjd » Thu Jan 15, 2015 3:34 pm

Let me preface this by saying that my knowledge of scripting is minimal and any script I develop usually ends up looking like a hack job :D

I am looking to piece together a script where:
Backup job at Site A starts
executes a script that will check a replication job at Site B to ensure it is not currently running.
It will then keep the backup job at Site A from executing until the replication job has finished.

I understand this will require some sort of invoke command
Invoke-Command -comp RepositoryFQDN -scriptblock {ScriptBlock} , as well as some sort of do while or do until loop that continues to check the status
( $Job = Get-VBRJob -name "Name of replication Job"
$Job.GetLastState() -eq "Working" ) of the remote job say every 60 minutes and once it sees the status as not working, then will allow the current job to proceed.

This will allow me to avoid the situation where a replication job may run several hours past the expected time. This only really occurs though on our 2 file servers that have Windows 2012 enabled which will, in turn, kick off a larger than normal incremental replication job occasionally based no the Windows 2012 deduplication/garbage collection/scrubbing process.

Thanks!
getzjd
Influencer
 
Posts: 21
Liked: 3 times
Joined: Mon Mar 12, 2012 3:10 am
Location: Cincinnati, OH
Full Name: Jay

Re: Script to Check Working status at remote site

Veeam Logoby v.Eremin » Thu Jan 15, 2015 5:20 pm

The following example should shed some light on how to check a job state and execute a second one in accordance:

Code: Select all
$Job = Get-VBRJob -name "Name of replication Job"
do{
Start-sleep -s 60
}while ($Job.GetLastState() -eq "Working")
Get-VBRJob -name "Name of second Job" | Start-VBRJob


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

Re: Script to Check Working status at remote site

Veeam Logoby getzjd » Tue Jun 02, 2015 12:20 pm

I haven't had much time to test this, however, how would the call be handled when checking on remote servers? For example: Server A has backup job C that may run for an extended period of time. Server B has replication job D that shouldn't start until Backup job C on Server A is completed.

Again, excuse my ignorance on scripting.
Thanks
getzjd
Influencer
 
Posts: 21
Liked: 3 times
Joined: Mon Mar 12, 2012 3:10 am
Location: Cincinnati, OH
Full Name: Jay

Re: Script to Check Working status at remote site

Veeam Logoby v.Eremin » Tue Jun 02, 2015 12:39 pm

The best idea would be set a script as post activity for backup job C. Once the backup job C is finished, post-job activity will be started. Within the script connection to site B will be setup, and replication job D will be executed. Thanks.
v.Eremin
Veeam Software
 
Posts: 13266
Liked: 968 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin


Return to PowerShell



Who is online

Users browsing this forum: No registered users and 8 guests