12-03-2014 01:29 PM
Hello.
Hoping this is pretty simple. I'm looking for a PowerShell script which would only restart services (via Restart-BEService) once all active jobs are done. I'll put this into a scheduled task and run once per day.
Thanks!
12-03-2014 11:02 PM
Check these two files in Backup Exec folder upon navigating to the installation directory.
Default Location: C:\Program Files\Symantec\Backup Exec\
File 1: BESTART.BAT
File 2: BESTOP.BAT
See if it helps in achieving what you need. Thanks!!
12-04-2014 09:03 AM
12-10-2014 08:05 AM
Sym-cr@zy, thanks but I'm looking for a method using PowerShell so I can query the current state of the jobs and ensure that they are not running when a restart happens.
pkh, the service restart is a workaround to using external USB hard drives as backup media. I never found a mechanism to "eject" a USB HDD from Backup Exec, so I do a safe remove through Windows. When I plug the next drive in, Backup Exec sees it and places it online, however when the job actually runs, it errors out and the drive gets placed in offline status. The service restart avoids this, but a few jobs have failed when the restarts occurred in the midst of a job, so querying the jobs for their status prior to the Restart-BEService cmdlet would solve that.
Of course, if you have any insights on the original issue, that would be even better!
12-10-2014 08:49 AM
Instead of a service restart, you can add a pre-command to the first scheduled backup job to bring the disk storage online so that the backup doesn't fail with the disk being offline.
Sample pre-command:-
CD\
powershell.exe -command "&{import-module bemcli;Get-BEDiskStorageDevice | Set-BEDiskStorageDevice -Disabled $false}"
12-11-2014 04:02 AM
12-18-2014 01:32 PM
VJware, thanks! I will try that.
I played with BEMCLI and came up with this. I think I'm close, but the loop seems to be infinite. Any thoughts on how I can fix this? The script is supposed to check for active jobs, wait until they are no longer active, then do a service restart.
# Init variable.
$ActiveJobs = Get-BEJob -IsActive $True
# Force a restart cycle when condition is met.
ForEach ($Job in $ActiveJobs)
{
If ($Job.IsActive -eq $True)
{
Do
{
Echo $Job.Name " is active, waiting 10 seconds..."
Sleep 10
}
Until ($Job.IsActive -eq $False)
}
}
Restart-BEService