PowerShell script exchange
Post Reply
paulhadley
Novice
Posts: 5
Liked: never
Joined: Nov 20, 2012 11:03 pm
Full Name: Paul Hadley
Contact:

Script to stop application service in guest OS during backup

Post by paulhadley »

Hi,

Apologies is if this isn't the correct place to enquire about this, but I was advised by Veeam support to ask here for help.

I need to backup a server that has application called Good for Enterprise installed using Veeam. Good Technology require that the 'GoodLinkServer' service is stopped on the server whilst it is backed up. This is required other wise the application is classed as unsupported. The server in question has a flat file database, I believe they wont the service stopped as they are trying to remove the risk of corruption on the DB.

I have tried using VM Tools quiescence to get this to work, however the script I am using only stops the service whilst the snapshot is creating then starts it straight after it is created, not for the duration of the backup or when removing the snapshot.

Current script for testing: C:\Program Files\VMware\VMware Tools\backupScripts.d\vcb.bat
if "%1%" == "freeze" goto doFreeze
if "%1%" == "freezeFail" goto doFreezeFail
if "%1%" == "thaw" goto doThaw

:doFreeze
C:\Windows\pre-freeze-script.bat
goto EOF

:doFreezeFail
C:\Windows\post-thaw-script.bat
goto EOF

:doThaw
C:\Windows\post-thaw-script.bat
goto EOF

:EOF

Can you advise how I may be able to stop the "GoodLinkServer" service for the duration of the backup please?
Vitaliy S.
VP, Product Management
Posts: 27377
Liked: 2800 times
Joined: Mar 30, 2009 9:13 am
Full Name: Vitaliy Safarov
Contact:

Re: Script to stop application service in guest OS during ba

Post by Vitaliy S. »

Hi Paul,
paulhadley wrote:Good Technology require that the 'GoodLinkServer' service is stopped on the server whilst it is backed up
Just to make sure I understand the limitations of your application - when you create a VM snapshot with a stopped application service, this very VM image is transferred to the repository where VM backup file is created. So technically you have met the requirements that tell you to stop the service during backup. Keeping the service in question in a stopped state for the entire time required to copy the snapshot data should not be necessary, at least for applications with similar requirements.

Can you please confirm that you need to keep your application service in a stopped state when VM snapshot is committed?

Thanks!
paulhadley
Novice
Posts: 5
Liked: never
Joined: Nov 20, 2012 11:03 pm
Full Name: Paul Hadley
Contact:

Re: Script to stop application service in guest OS during ba

Post by paulhadley »

Yes. I will need to keep the application in a stopped state when the snapshot is committed. Is this possible?
Vitaliy S.
VP, Product Management
Posts: 27377
Liked: 2800 times
Joined: Mar 30, 2009 9:13 am
Full Name: Vitaliy Safarov
Contact:

Re: Script to stop application service in guest OS during ba

Post by Vitaliy S. »

VMware Tools allow to execute scripts on pre-freeze and post-thaw operations, so the only way to achieve what you're after is to do the following:

1. Execute just a pre-freeze script via VMware Tools to stop the application service, don't run post-thaw scripts.
2. Once the job is complete, use a post-backup job option to execute the script that would start the service inside the backed up VM.

Should do the trick!
paulhadley
Novice
Posts: 5
Liked: never
Joined: Nov 20, 2012 11:03 pm
Full Name: Paul Hadley
Contact:

Re: Script to stop application service in guest OS during ba

Post by paulhadley »

That sounds like a good solution. With regards to post-backup job option are you talking about, Storage - Advanced settings - Advanced - Post job activity? Will this run a script inside my guest OS or locally on my VBR server?
Vitaliy S.
VP, Product Management
Posts: 27377
Liked: 2800 times
Joined: Mar 30, 2009 9:13 am
Full Name: Vitaliy Safarov
Contact:

Re: Script to stop application service in guest OS during ba

Post by Vitaliy S. »

Yes, I'm referring to this option. It will execute a script on your backup server, however you can use something like PSexec to execute this script against the remote VM. Thanks!
paulhadley
Novice
Posts: 5
Liked: never
Joined: Nov 20, 2012 11:03 pm
Full Name: Paul Hadley
Contact:

Re: Script to stop application service in guest OS during ba

Post by paulhadley »

Ok, great. I can see how this would work with PSexec, however is it possible to do this without storing credentials and passing them in plain text?
Vitaliy S.
VP, Product Management
Posts: 27377
Liked: 2800 times
Joined: Mar 30, 2009 9:13 am
Full Name: Vitaliy Safarov
Contact:

Re: Script to stop application service in guest OS during ba

Post by Vitaliy S. »

Quick google search returned me this article, you may want to give it a try: http://dereknewton.com/2010/06/psexec-p ... lear-text/
paulhadley
Novice
Posts: 5
Liked: never
Joined: Nov 20, 2012 11:03 pm
Full Name: Paul Hadley
Contact:

Re: Script to stop application service in guest OS during ba

Post by paulhadley »

Hi Vitaliy,

Thanks for your help. I have has a look through the guide that you sent for PsExec passing credentials in clear text. But the problem is I wouldn't be allowed to store them in clear text on the management servers either. Then we had a thought of using windows scheduled tasks to manage the credentials side, but I cant get that to work unless I was logged on, even with the appropriate options in place.

My next thoughts are if it would be easier just to power down the VM, back it up and power it back on. But ideally I want an solution that is directly linked to the Veeam job. So rather than doing with with scheduled tasks in the vCenter. I could power it down using VMtools and a script in the guest OS. But is it possible that I could use a script to power on the VM with via Veeam - post job,if I gave the Veeam service account permissions in the vcenter?

Thanks,

Paul.
veremin
Product Manager
Posts: 20413
Liked: 2301 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Script to stop application service in guest OS during ba

Post by veremin »

You can use both PowerCLI and VeeamPSSnapin to achieve what you are after. So, within the script you should issue poweroff commands first (Stop-VM, then, execute backup job (Start-VM), and, finally, powerup VM (Start-VM). In order to power up/down VM you will have to connect to vCenter (Connect-VIServer), using valid credentials. The credentials can be stored be in secure way, and there are several ways how you can do it (1,2).

Thanks.
Post Reply

Who is online

Users browsing this forum: No registered users and 16 guests