Showing posts with label sqlmaint. Show all posts
Showing posts with label sqlmaint. Show all posts

Wednesday, March 7, 2012

run backup (maintenance plan) from Batch (.bat) file

What is the method to execute backups from batch (.bat) files on the server running SQL Server. I have tried the sqlmaint command - doesn't seem to execute, looked into the xp_sqlmaint with no luck. I'm sure the problem lies in my lack of DOS batch programming skills. If anyone has an example of a batch file that executes a backup would you mind sharing. thanksHave you tried using OSQL from within a batch file?|||just stumbled onto that option this morning. I'm not much of a SQL guru, tring to set up some backups of DB contained in SQL from an COTS package. Do you know how this would all fit together? It appears I would create a file with (possiblely) the SQLMAINT (statement and parms) contained within. Then execute it from within the OSQL statement. Does this sound like I'm on the right track? Do you use the OSQL statement in any .BAT files? I would love to see an example of a (.BAT & sqlmaint) file that I could mimic the context of.|||personally I do not use maintenance plans. I script out all of my maintenance using BACKUP and DBCC t-sql statements. And yu can probably do this with osql in a batch file.

Why may I ask are you taking this approach? Do you need to schedule these to run at a specific time? If so, why not use a sql server agent job?|||I want to have it executed by the server backup software right before the backup system: tivoli, TSM, (not sure of the specific tool) runs. I also want to include some file ZIPs and versioning (file rolls - moves - to specific folders) to mimic the backup/DR process used for other products on the server (a comprehebnsive backup/recovery porocess used for our COTS tools)|||you can use jobs in the sql server agent to do all of that. I would go to SQL Server books Online-->Contents-->Administering SQL Server--> Automating Administrative Tasks-->Implimenting Jobs and do some reading.

you may also want to read xp_cmdshell for the file copies|||thanks I will...I just can't believe that there isn't a fairly easy way to do it extrnally so that I can leverage my existing BAT files and scheduling software (autosys)