-
- Veteran
- Posts: 600
- Liked: 66 times
- Joined: Jun 13, 2013 10:08 am
- Full Name: Paul Kelly
- Contact:
Stopping BExec services on remote (tape) server
I'm parallel running Veeam tape backups & BExec (can only get rid of BE once I now I fully understand Veeams tape side of things) but obviously conflict issues even though I have a dedicated tape library I can use.
So, right now I'd like to just run a pre-job to stop BExec services and a post-job to start them again.
So far I have enabled remoting on the physical tape server (B&R server is a dedicated VM) and I have a powershell script on the B&R server that will successfully start/stop the services simply by executing the script in a "standard" (as opposed to "run as administrator") powershell console so I know the whole remoting side of things is working perfectly.
However, the pre/post jobs are stating the script is executed but they obviously complete too quickly for it to actually have run so I'm not sure what I need to do differently to get Veeam to execute the scripts properly.
The stop script is simply this (start scipt is identical but obviously "Start-service"):
#############################
#Stop Backup Exec Services on <TAPE-SERVER>
get-service -Name BackupExecAgentBrowser -Computername <TAPE-SERVER> | Stop-service
get-service -Name BackupExecJobEngine -Computername <TAPE-SERVER> | Stop-service
get-service -Name BackupExecRPCService -Computername <TAPE-SERVER> | Stop-service
get-service -Name BackupExecDeviceMediaService -Computername <TAPE-SERVER> | Stop-service
get-service -Name BackupExecAgentAccelerator -Computername <TAPE-SERVER> | Stop-service
#############################
Note I don't seem to need "new-pssession" in the above code?
I'm not using any Veeam-specific code so presumably I don't need to Add-VeeamPsSnap either?
Any suggestions welcome (I only occasionally dabble in PS & generally cobble stuff together based on research but haven't found anything where Veeam stops remote services as I'd concede it's probably not a common requirement!
So, right now I'd like to just run a pre-job to stop BExec services and a post-job to start them again.
So far I have enabled remoting on the physical tape server (B&R server is a dedicated VM) and I have a powershell script on the B&R server that will successfully start/stop the services simply by executing the script in a "standard" (as opposed to "run as administrator") powershell console so I know the whole remoting side of things is working perfectly.
However, the pre/post jobs are stating the script is executed but they obviously complete too quickly for it to actually have run so I'm not sure what I need to do differently to get Veeam to execute the scripts properly.
The stop script is simply this (start scipt is identical but obviously "Start-service"):
#############################
#Stop Backup Exec Services on <TAPE-SERVER>
get-service -Name BackupExecAgentBrowser -Computername <TAPE-SERVER> | Stop-service
get-service -Name BackupExecJobEngine -Computername <TAPE-SERVER> | Stop-service
get-service -Name BackupExecRPCService -Computername <TAPE-SERVER> | Stop-service
get-service -Name BackupExecDeviceMediaService -Computername <TAPE-SERVER> | Stop-service
get-service -Name BackupExecAgentAccelerator -Computername <TAPE-SERVER> | Stop-service
#############################
Note I don't seem to need "new-pssession" in the above code?
I'm not using any Veeam-specific code so presumably I don't need to Add-VeeamPsSnap either?
Any suggestions welcome (I only occasionally dabble in PS & generally cobble stuff together based on research but haven't found anything where Veeam stops remote services as I'd concede it's probably not a common requirement!
-
- Product Manager
- Posts: 6551
- Liked: 765 times
- Joined: May 19, 2015 1:46 pm
- Contact:
Re: Stopping BExec services on remote (tape) server
Hi,
This part fetches the specified service from your tape server and treat it as an object, so far so good, but in this part
You actually pipe that object to a local machine Stop-service cmdlet, instead of passing it to a remote machine. That is you might actually need new-pssession. There is also another way:
Thank you.
Not sure what you mean by "too quickly"? Does veeam job starts earlier than your pre-job script manages to stop BE services? Please elaborate.However, the pre/post jobs are stating the script is executed but they obviously complete too quickly for it to actually have run so I'm not sure what I need to do differently to get Veeam to execute the scripts properly.
Might be a dumb question but have you tried issuing this command manually on your VBR server? Did it actually manage to stop remote BE service? The reason behind my question:get-service -Name BackupExecAgentBrowser -Computername <TAPE-SERVER> | Stop-service
This part
Code: Select all
get-service -Name BackupExecAgentBrowser -Computername <TAPE-SERVER>
Code: Select all
| Stop-service
Code: Select all
Get-Service -Name SERVICENAME -ComputerName SERVERNAME | Set-Service -Status Running
Correct.I'm not using any Veeam-specific code so presumably I don't need to Add-VeeamPsSnap either?
Thank you.
-
- Veteran
- Posts: 600
- Liked: 66 times
- Joined: Jun 13, 2013 10:08 am
- Full Name: Paul Kelly
- Contact:
Re: Stopping BExec services on remote (tape) server
Sorry, I mean there's no wait/delay after the "Running pre-job script" - it immediately goes onto job processing, i.e. there's no wait for the services to stop (see below)Not sure what you mean by "too quickly"? Does veeam job starts earlier than your pre-job script manages to stop BE services? Please elaborate.
Perfectly reasonable question: Yes I have. I opened a basic (non-admin) Powershell console & dragged the script into it. It runs perfectly & it outputs feedback such as "Stopping service <servicename>... with a delay between each one so takes, maybe, 10-15 seconds to stop all services, so this is the delay I'd have expected the script to run for before going into the next stage of the job (actually processing files etc.)get-service -Name BackupExecAgentBrowser -Computername <TAPE-SERVER> | Stop-service
Might be a dumb question but have you tried issuing this command manually on your VBR server? Did it actually manage to stop remote BE service? The reason behind my question:
Hmm, but as mentioned above, the code works perfectly if running in PS console?<...>You actually pipe that object to a local machine Stop-service cmdlet, instead of passing it to a remote machine. That is you might actually need new-pssession<...>
Thanks for confirmation.Correct
Thank you.
-
- Veteran
- Posts: 600
- Liked: 66 times
- Joined: Jun 13, 2013 10:08 am
- Full Name: Paul Kelly
- Contact:
Re: Stopping BExec services on remote (tape) server
Actually I just had another play & thought I'd do a further test by copying & pasting the exact line of the job into a cmd shell (i.e. running powershell with the script as an argument) and spotted a flaw that I'd created when simplifying the script (I've changed it to specify the target BExec server as an argument) and discovered that I'd entered the script incorrectly as:
C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -noninteractive -file "C:\Scripts\BEStart.ps1 <servername>"
Where it needed to be:
C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -noninteractive -file "C:\Scripts\BEStart.ps1" <servername>
(last quote in different place)
That also runs perfectly now in CMD shell and no longer generates an error in the Veeam job but having made that modification I noticed something.
1) Editing the job caused it to restart (it's a continuous job) which caused the pre-job script to run & it reported sucessful running
2) It's now (expectedly) "Waiting for new restore points..." but no post-job script has run.
So, potentially if my script was working (the services weren't stopped after the job restart above) then it would now be sitting with all BExec services stopped, & only restart them after the next copy cycle?
This doesn't feel right to me at all, I'd have thought the pre/post should happen immediately surrounding any "movement" of the job, or am I missing something?
C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -noninteractive -file "C:\Scripts\BEStart.ps1 <servername>"
Where it needed to be:
C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -noninteractive -file "C:\Scripts\BEStart.ps1" <servername>
(last quote in different place)
That also runs perfectly now in CMD shell and no longer generates an error in the Veeam job but having made that modification I noticed something.
1) Editing the job caused it to restart (it's a continuous job) which caused the pre-job script to run & it reported sucessful running
2) It's now (expectedly) "Waiting for new restore points..." but no post-job script has run.
So, potentially if my script was working (the services weren't stopped after the job restart above) then it would now be sitting with all BExec services stopped, & only restart them after the next copy cycle?
This doesn't feel right to me at all, I'd have thought the pre/post should happen immediately surrounding any "movement" of the job, or am I missing something?
-
- Product Manager
- Posts: 6551
- Liked: 765 times
- Joined: May 19, 2015 1:46 pm
- Contact:
Re: Stopping BExec services on remote (tape) server
True. Just tested it myself - it seems that the code works differently depending on a PS version.Hmm, but as mentioned above, the code works perfectly if running in PS console?
Just want to make sure I got it right - in which job did you specify your pre/post job scripts? Is it a simple Backup job?1) Editing the job caused it to restart (it's a continuous job) which caused the pre-job script to run & it reported sucessful running
2) It's now (expectedly) "Waiting for new restore points..." but no post-job script has run.
Thank you.
-
- Veteran
- Posts: 600
- Liked: 66 times
- Joined: Jun 13, 2013 10:08 am
- Full Name: Paul Kelly
- Contact:
Re: Stopping BExec services on remote (tape) server
Using v1 to execute the scripts in both places.
This is all in a "Backups to Tape" job, source being local job / repository.
This is all in a "Backups to Tape" job, source being local job / repository.
-
- Product Manager
- Posts: 6551
- Liked: 765 times
- Joined: May 19, 2015 1:46 pm
- Contact:
Re: Stopping BExec services on remote (tape) server
Correct. So your prejob script has succesfully started though BE services are still running?So, potentially if my script was working (the services weren't stopped after the job restart above) then it would now be sitting with all BExec services stopped, & only restart them after the next copy cycle?
If no post-job script will be executed after a copy cycle finishes then you can contact our support team and post post your case ID in this thread.It's now (expectedly) "Waiting for new restore points..." but no post-job script has run.
Thank you.
-
- Veteran
- Posts: 600
- Liked: 66 times
- Joined: Jun 13, 2013 10:08 am
- Full Name: Paul Kelly
- Contact:
Re: Stopping BExec services on remote (tape) server
Yes, Script reported as "Pre-job script completed successfully", and I have a debug line in it writing to a (local) log file to confirm that it has executed, but the service is still running.
The next line in job status is "Waiting for new restore points".
I'll have to hold off logging a call as I logged a different one yesterday & so today was asked by support to update to Patch 3 which I've scheduled for tomorrow evening. So I shall test again after that patch & if not fixed, log another case & report back here.
Thanks for your input...
The next line in job status is "Waiting for new restore points".
I'll have to hold off logging a call as I logged a different one yesterday & so today was asked by support to update to Patch 3 which I've scheduled for tomorrow evening. So I shall test again after that patch & if not fixed, log another case & report back here.
Thanks for your input...
-
- Veteran
- Posts: 600
- Liked: 66 times
- Joined: Jun 13, 2013 10:08 am
- Full Name: Paul Kelly
- Contact:
Re: Stopping BExec services on remote (tape) server
Out of interest I looked into the version difference issue you mentioned as I have seen it mentioned elsewhere so to test against that issue further I used the following in my script:
$svc = Get-Service -Name bedbg -ComputerName $beserver
Stop-Service -InputObject $svc
It didn't make any difference but to force the script to run I stopped & started the job manually, somehow I ended up disabling it & noted that, when starting it from a disabled state, although it still didnt stop the service, the steps performed exactly as I'd expect them to:
Job started...
Pre-job script...
No new files...
Post job script...
Job finished.
$svc = Get-Service -Name bedbg -ComputerName $beserver
Stop-Service -InputObject $svc
It didn't make any difference but to force the script to run I stopped & started the job manually, somehow I ended up disabling it & noted that, when starting it from a disabled state, although it still didnt stop the service, the steps performed exactly as I'd expect them to:
Job started...
Pre-job script...
No new files...
Post job script...
Job finished.
-
- Product Manager
- Posts: 6551
- Liked: 765 times
- Joined: May 19, 2015 1:46 pm
- Contact:
Re: Stopping BExec services on remote (tape) server
Could you please try to call your .ps1 via a separate .bat ? In other words specify .bat file as a pre-job script file and place "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -noninteractive -file "C:\Scripts\BEStart.ps1" inside that .bat file. Also I think that placing a delay inside .bat is worth trying.
Thank you.
Thank you.
-
- Veteran
- Posts: 600
- Liked: 66 times
- Joined: Jun 13, 2013 10:08 am
- Full Name: Paul Kelly
- Contact:
Re: Stopping BExec services on remote (tape) server
OK, I've configured it via .bat file now so will see tonight.
Out of interest, how long a delay are you suggesting and for what purpose?
Out of interest, how long a delay are you suggesting and for what purpose?
-
- Product Manager
- Posts: 6551
- Liked: 765 times
- Joined: May 19, 2015 1:46 pm
- Contact:
Re: Stopping BExec services on remote (tape) server
I believe that BExec services won't stop instantly after you've issued a stop-service command via powershell so placing a 10-15 secinds delay insise .bat file will make it to wait before starting the job. Another approach would be to place a loop that is constantly checking for BExec service status and terminates once all services are stopped.Out of interest, how long a delay are you suggesting and for what purpose?
Ok, looking forward to hear from you.OK, I've configured it via .bat file now so will see tonight.
Thank you.
-
- Veteran
- Posts: 600
- Liked: 66 times
- Joined: Jun 13, 2013 10:08 am
- Full Name: Paul Kelly
- Contact:
Re: Stopping BExec services on remote (tape) server
OK, unfortunately no change except that at least the pre/post scripts no longer complain of timeouts. The scripts are executed (as I can see in my output to log file) but the services aren't touched.
Again, to confirm I dragged the .bat versions of the scripts into a "standard" (i.e. not "run as administrator") CMD prompt and they execute perfectly as-is.
I think it must be something to do with the context that Veeam is executing the scripts in?
Again, to confirm I dragged the .bat versions of the scripts into a "standard" (i.e. not "run as administrator") CMD prompt and they execute perfectly as-is.
I think it must be something to do with the context that Veeam is executing the scripts in?
-
- Product Manager
- Posts: 20415
- Liked: 2302 times
- Joined: Oct 26, 2012 3:28 pm
- Full Name: Vladimir Eremin
- Contact:
Re: Stopping BExec services on remote (tape) server
The scripts are executed under Veeam service account. As an additional check, it might be worth confirming (manually) whether the script does it job correctly, if executed under Veeam service account. Thanks.
-
- Veteran
- Posts: 600
- Liked: 66 times
- Joined: Jun 13, 2013 10:08 am
- Full Name: Paul Kelly
- Contact:
Re: Stopping BExec services on remote (tape) server
I just logged into the B&R server directly as the service account, opened a standard CMD prompt (not run as admin) and successfully ran both the stop & start .bat files which stopped & started the remote BExec services as expected using the same .bat files specified in the pre/post-job options.
-
- Product Manager
- Posts: 20415
- Liked: 2302 times
- Joined: Oct 26, 2012 3:28 pm
- Full Name: Vladimir Eremin
- Contact:
Re: Stopping BExec services on remote (tape) server
I have several suggestions:
- If PS 2.0 is used, update to 3.0 at least
- Check whether during manual and automatic tests the same version of PS is leveraged. In x64 OS there are two instances of PS - 32 and 64 ones
- Put a server name within a single quotes in a bat file. 'ServerName'
If nothing helps, open a ticket with our support team.
Thanks.
- If PS 2.0 is used, update to 3.0 at least
- Check whether during manual and automatic tests the same version of PS is leveraged. In x64 OS there are two instances of PS - 32 and 64 ones
- Put a server name within a single quotes in a bat file. 'ServerName'
If nothing helps, open a ticket with our support team.
Thanks.
-
- Veteran
- Posts: 600
- Liked: 66 times
- Joined: Jun 13, 2013 10:08 am
- Full Name: Paul Kelly
- Contact:
Re: Stopping BExec services on remote (tape) server
Will go through those when I return from holiday and as suggested, log a ticket if no joy. Thanks again.
-
- Veteran
- Posts: 600
- Liked: 66 times
- Joined: Jun 13, 2013 10:08 am
- Full Name: Paul Kelly
- Contact:
Re: Stopping BExec services on remote (tape) server
I'm pleased to report that having now upgraded to v9, U1 (from v8) my original scripts seem to be running exactly as expected! (This is using a .bat to call a .ps1 - I haven't tried seeing if natively running a .ps1 also works as what I have now is good enough for me.
My last niggle with it though is I think I might need to initiate a rescan of the tape server for it to realise that the tape library is now available for use - can someone suggest what's the easiest powershell command to achieve that?
My last niggle with it though is I think I might need to initiate a rescan of the tape server for it to realise that the tape library is now available for use - can someone suggest what's the easiest powershell command to achieve that?
-
- Product Manager
- Posts: 20415
- Liked: 2302 times
- Joined: Oct 26, 2012 3:28 pm
- Full Name: Vladimir Eremin
- Contact:
Re: Stopping BExec services on remote (tape) server
From the top of my head:
Thanks.
Code: Select all
Get-VBRTapeServer -Name "Name of your Tape Server" | Rescan-VBREntity
-
- Veteran
- Posts: 600
- Liked: 66 times
- Joined: Jun 13, 2013 10:08 am
- Full Name: Paul Kelly
- Contact:
Re: Stopping BExec services on remote (tape) server
Thanks! I've inserted it into my script & will see how it goes...
-
- Product Manager
- Posts: 20415
- Liked: 2302 times
- Joined: Oct 26, 2012 3:28 pm
- Full Name: Vladimir Eremin
- Contact:
Re: Stopping BExec services on remote (tape) server
I'd suggest to run it independently first just to check whether everything works as expected and then incorporate this portion into the script. Thanks.
Who is online
Users browsing this forum: No registered users and 11 guests