Comprehensive data protection for all workloads
Post Reply
kapple
Enthusiast
Posts: 76
Liked: 4 times
Joined: Jun 14, 2012 7:13 pm
Full Name: Ken Applebaum
Location: Rochester, NY
Contact:

Post job scripts with multiple VMs in the job

Post by kapple »

Hi,

First, I am running Veeam 9.0.0.1491 on Windows server 2008 R2.

We have some application/database server pairs that that are backed up. When the snapshot commits after the backup, sometimes the application listeners that communicate with the DB servers hiccup. They still run, but the connection is broken long enough, that the application no longer works. The usual fix is to restart any application listeners.

I thought this would be a great opportunity to try a post processing script. I created a backup job for 2 Windows servers, one an application server, one a database server. At the end of the job, I want Windows services on each server to restart.

Since I can only run one post processing script per job, I have all the commands in the same .bat file. The commands are:

Code: Select all

@echo off
REM This will stop the windows services
sc stop developmentSQL_APP_LISTENER
sc stop developmentSQL_DB_LISTENER
REM This will pause this script for 30 seconds
timeout /t 30
REM This will start the windows services
sc start developmentSQL_DB_LISTENER
timeout /t 10
sc start developmentSQL_APP_LISTENER
The developmentSQL_APP_LISTENER Windows service runs on the application server, and the developmentSQL_DB_LISTENER Windows service runs on the database server. I want to test my understanding of how this will work, since this script will run on both servers.

First, the script is hosted on the Veeam B&R server, but the command are run on the servers that are being backed up, correct?

Second, the call to stop and start a service that does not run on one server, will fail, but the call to stop and stop a service that does run on the server should succeed, correct?

Unfortunately, there are no Windows event log entries on either server indicating that the service stopped or started.
Furthermore, from the Veeam backup job log, there is the following warning:
11/21/2016 5:37:38 PM :: Post-job script terminated with exit code 1060

From what I am describing, am I doing this correctly? I realize I can configure backup jobs that only process one server. However, since jobs do queue, I don't want one server's listener to restart, then have the other backup job break the app server/DB server connection again.

Any feedback and advice will be greatly appreciated.

Thanks,
Ken
PTide
Product Manager
Posts: 6431
Liked: 729 times
Joined: May 19, 2015 1:46 pm
Contact:

Re: Post job scripts with multiple VMs in the job

Post by PTide »

Hi,
First, the script is hosted on the Veeam B&R server, but the command are run on the servers that are being backed up, correct?
No, the script is executed on VBR server so if you want to perform some actions on the VMs being backed up you should write such script that logs in the target VM and perform required actions.
Post-job script terminated with exit code 1060
Scripts is considered to be executed successfully only if it returns 0 code.
I don't want one server's listener to restart, then have the other backup job break the app server/DB server connection again.
You don't have to - just change your script so it affect only one server.

Thanks
kapple
Enthusiast
Posts: 76
Liked: 4 times
Joined: Jun 14, 2012 7:13 pm
Full Name: Ken Applebaum
Location: Rochester, NY
Contact:

Re: Post job scripts with multiple VMs in the job

Post by kapple »

Hi PTide,

So from what you are telling me, I should have the .bat file point to the service on the target VM. Since Veeam B&R only gives the option to run a script that is hosted on the B&R server, I need to figure out how to run these commands on the remote machine from this script. I know this is asking for more than my original post, but would this do the trick?

Code: Select all

@echo off
REM This will stop the windows services
sc \\appservername stop developmentSQL_APP_LISTENER
sc \\dbservername stop developmentSQL_DB_LISTENER
REM This will pause this script for 30 seconds
timeout /t 30
REM This will start the windows services
sc \\dbservername start developmentSQL_DB_LISTENER
net start developmentSQL_DB_LISTENER
timeout /t 10
sc \\appservername start developmentSQL_APP_LISTENER
net start  developmentSQL_APP_LISTENER
Thanks,
- Ken
PTide
Product Manager
Posts: 6431
Liked: 729 times
Joined: May 19, 2015 1:46 pm
Contact:

Re: Post job scripts with multiple VMs in the job

Post by PTide »

I guess you can just place a script to be executed on the target VM and use post-job script to login into the VM and trigger the script from the inside.
kapple
Enthusiast
Posts: 76
Liked: 4 times
Joined: Jun 14, 2012 7:13 pm
Full Name: Ken Applebaum
Location: Rochester, NY
Contact:

Re: Post job scripts with multiple VMs in the job

Post by kapple »

I tested a script remotely stopping and starting a service on my workstation, and it worked.
Of course, the rub will be making this work on 2 separate servers. I am going to try this out on tonight's backup:

Code: Select all

@echo off
@echo off
REM This will stop the windows services
sc \\appservername stop developmentSQL_APP_LISTENER
sc \\dbservername stop developmentSQL_DB_LISTENER
REM This will pause this script for 30 seconds
timeout /t 30
REM This will start the windows services
sc \\dbservername start developmentSQL_DB_LISTENER
net start developmentSQL_DB_LISTENER
timeout /t 15
sc \\appservername start developmentSQL_APP_LISTENER
net start developmentSQL_APP_LISTENER
veremin
Product Manager
Posts: 20284
Liked: 2258 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Post job scripts with multiple VMs in the job

Post by veremin »

Be aware that the post job command will be executed under Veeam service account (the one veeam specific services are running), so make sure that it has required permissions on the target machine. Thanks.
kapple
Enthusiast
Posts: 76
Liked: 4 times
Joined: Jun 14, 2012 7:13 pm
Full Name: Ken Applebaum
Location: Rochester, NY
Contact:

Re: Post job scripts with multiple VMs in the job

Post by kapple » 1 person likes this post

Hi,

Yes, the account has appropriate permissions to execute the script on the backup target.
I also realize that I don't need all the commands I was using.
This works fine:

Code: Select all

sc \\appservername start developmentSQL_APP_LISTENER
This is redundant:

Code: Select all

net start developmentSQL_APP_LISTENER
Post Reply

Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 104 guests