Solved

Backup and Restore DB using DOS Batch command

Posted on 2008-10-14
2
1,615 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

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

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

Suggested Solutions

Slowly Changing Dimension Transformation component in data task flow is very useful for us to manage and control how data changes in SSIS.
For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function
Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.

756 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