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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Backing up MSDE DB

Status
Not open for further replies.

Callahan

Technical User
Nov 21, 2001
174
GB
Hi,

I have written a batch file that calls osql to run a backup by passing a backup.sql file to osql.
Here's what I have:
A batch file containing the following:

osql -E -i c:\backup.sql

In the backup.sql file is the following:

BACKUP DATABASE BESMgmt TO DISK = 'C:\BES DB Backups\DBs\BESMgmt.bak'
BACKUP DATABASE master TO DISK = 'C:\BES DB Backups\DBs\master.bak'
BACKUP DATABASE model TO DISK = 'C:\BES DB Backups\DBs\model.bak'
BACKUP DATABASE msdbdata TO DISK = 'C:\BES DB Backups\DBs\msdbdata.bak'
BACKUP DATABASE temp TO DISK = 'C:\BES DB Backups\DBs\temp.bak'
Go

Yet when I run the batch file I get:

C:\Bes-DB-Backups\Batch-files>osql -E -i c:\backup.sql
Cannot open input file - c:\backup.sql
No such file or directory

Well it's lying! There is a file with that name in the location I've specified so why can't it find it? What am I doing wrong?

Thanks for any help you can offer.
 
OK ... so does your backup.sql script reside on the root of C: as you have it OR does it exist in the folder C:\Bes-DB-Backups\Batch-files.

If it is the later ... your OSQL would need to look like ...

osql -E -i C:\Bes-DB-Backups\Batch-files\backup.sql

Thanks

J. Kusch
 
I've tried both ways, in both locations. Neither of which work and both giving the same error message. It wouldn't have anything to do with running this through a terminal session would it? I can't see why it would....
 
I noticed a difference in the directory structure your .sql file has and where you are firing off the OSQL command.

Which is correct?

In the .sql file you have a directory structure of:

C:\Bes DB Backups\xxx

This has NO "-" in the parent folder.

Then your example shows you firing off the OSQL command in the directory:

C:\Bes-DB-Backups\

This DOES have "-" in the parent folder.

Which is correct or are they both correct and you have both a C:\Bes DB Backups\ and a C:\Bes-DB-Backups\ folder.

Now if it is the case that there are NO "-" in your folder names and that there are spaces " " instead ... then try:

Make sure the backup.sql file is in the

C:\Bes DB Backups\Batch files folder then execute the following command on the command line:

Code:
osql -E -i "C:\Bes DB Backups\Batch files\backup.sql"

Thanks

J. Kusch
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top