Solved

Backup and Restore DB using DOS Batch command

Posted on 2008-10-14
2
1,620 Views
Last Modified: 2012-05-05
Hi Everyone:

How could I stop the DB service, backup DB and restart the SQL Server 2005 in Batch command? My intention is to automate the process of backup of a DB to a remote location. Is there any better way to accomplish this task?

Thank in advance.

Regards,
LS
0
Comment
Question by:IVISMY
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 9

Accepted Solution

by:
Sander Stad earned 250 total points
ID: 22718346
I wouldn't stop de SQL Server service because than you wouldn't be able to execute any queries against it. You can use the following code to create a backup.
The osql.exe is replaced with "sqlcmd" in SQL Server 2005
The only reason why you should stop the SQL Service is when you just want to make a copy backup using the "COPY" or "XCOPY" command in de command line.
More information on the command:
"{sqlserverinstall}\80\Tools\Binn\osql.exe" -E -Q "BACKUP DATABASE {databasename} TO DISK='{location to copy to}' WITH FORMAT"

Open in new window

0

Featured Post

Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Slowly Changing Dimension Transformation component in data task flow is very useful for us to manage and control how data changes in SSIS.
Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.

627 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question