Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Pre/post commands not working correctly

Status
Not open for further replies.

mquinn0908

Technical User
Jul 3, 2002
335
US
I have the following batch files that run before and after a backup job to start SQL services on both the local machine and remote one to do a flat backup. The batch file does stop/start the services correctly on the remote server but the services on the local machine never stop. Can anyone give me a clue as to why?

commands to stop services:

@echo off
echo.
echo.Stopping the MSSQLSERVER service...
echo.
NETSVC "SQLSERVERAGENT" \\server name /stop >nul
PING 192.168.20.5 -n 10 -w 1000 >NUL
NETSVC "MSSQLSERVER" \\servername /stop >nul
NET STOP "SQL Server (MSSQLSERVER)" >nul
NET STOP "SQL Server Agent (MSSQLSERVER)" >nul


commands to start services:

@echo off
echo.
echo.Starting the MSSQLSERVER service...
echo.
NETSVC "SQLSERVERAGENT" \\server name /start >nul
echo.
echo.
echo.
echo.
NETSVC "MSSQLSERVER" \\server name /start >nul
NET START "SQL Server (MSSQLSERVER)" >nul
NET START "SQL Server Agent (MSSQLSERVER)" >nul


Mandy
MCP/A+/Network+
 
There is no reason to be stopping your SQL services on any machine. Have your SQL engine make it's own backup, then store that to tape.
 
It has always been very convienent to just stop the services before the backup and then start them up when the job was over as I am not very familiar with SQL and I am not sure how long the SQL engine takes to backup the data so I don't know when to schedule it so it finishes before the backup exec job runs.

Mandy
MCP/A+/Network+
 
What version of Backup exec?
There are option in 10d and 11d in pre/post command section on how to run the pre/post. THe path must be same for all the batch file on all servers
 
This is version 9.1 and it does have a section for running the pre and post commands and it does run the problem is it only stops the services on the remote server and not the ones on the local server. The path is correct on the backup server. If I take out the portion of the file that stops the services on the remote server then the local services will stop but if I put the command to stop the remote services back in then only the services on the remote server stop and not the ones on the local server.


Mandy
MCP/A+/Network+
 
I assume that buying the SQL Agent is an option?
Using SQL to create its own flat-file backups is fairly quick, but if you have large databases, it requires you to have plenty of disk space free.

The SQL service on the local machine - does it contain anything other than the BE database? If not, there's no need to back it up, as the database maintenance process creates the BEDB.bak file, which is used for database recovery.

 
I do have the sql agent but as backup exec is version 9.1 and I am trying to backup a sql 2005 database it won't allow this. The sql service on the local machine does contain databases other than the BE database and it is very important that I get these backed up.

Mandy
MCP/A+/Network+
 
Well that's a good enough reason!
If you can live with the databases being down during the backup, the method you're trying seems the right way.

Shouldn't the syntax for the last 2 lines simply be:

NET STOP "SQLSERVERAGENT" >nul
NET STOP "MSSQLSERVER" >nul

And similarly for the net start command.

 
SQL Server (MSSQLSERVER)and SQL Server Agent (MSSQLSERVER) is how they are listed in the services applet in administrative tools.

Mandy
MCP/A+/Network+
 
IIRC, the description in the Services MMC and the service name don't neccessarily bear any resemblance to each other!
I just tested what I suggested on a test SQL2005 Express Edition database, and it worked for me.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top