Friday, February 24, 2012

backup MSDE

Hello,

i'm trying to make a backup for my MSDE database with that .bat file:

cd C:\Program Files\Microsoft SQL Server\80\Tools\Binn
BACKUP DATABASE db1 TO DISK = 'C:\MSDE-backup\db1.bak'
pause

I get the following error:
The filename, directory name, or a volume label is incorrect

What i know for sure is that db1 exist and C:\MSDE-backup\db1.bak exist too.

When we download sql2kdesksp3.exe, did we have everything to perform BACKUP and RESTORE or where is my mistake ?

MSDE database work properly and i can connect to it. I have sysadmin permission.

Thanks.don't you have to run this using osql?

cs|||it is not what I did ? where is my mistake ?|||you have to run the BACKUP command through osql.exe I don't see that in your batch file.

cs|||is it possible you give me the correct batch file because i don't understand. thanks.|||In your first line, you CD (change directory).

In your second line you are trying to call some program called "backup", which doesn't exist.

You need to write:

osql.exe <other stuff here
which will call osql.exe and pass in the appropriate parameters.

Cheers
Ken|||That does not work:

cd C:\Program Files\Microsoft SQL Server\80\Tools\Binn\
osql.exe
BACKUP DATABASE db1 TO DISK = 'C:\MSDE-backup\db1.bak'
pause|||What Ken is saying is that the BACKUP command is not a program or DOS command. It's a SQL command. As such, you have to have a way to send that command to SQL Server. OSQL.EXE is a program that accepts a SQL command as one of its parameters.

Try this...
cd C:\Program Files\Microsoft SQL Server\80\Tools\Binn\
osql.exe -q "BACKUP DATABASE db1 TO DISK = 'C:\MSDE-backup\db1.bak'" -E
pause|||I had the good and fast response of another forum:

cd C:\Program Files\Microsoft SQL Server\80\Tools\Binn\
osql -S servername -E -Q "BACKUP DATABASE db1 TO DISK = 'C:\MSDE-backup\db1.bak'"
pause

thanks anyway|||I first tried m33b example with no luck then ronba's AND IT WORKED.

Thanks for saving my sleepless night ;)...<|||Can this .bat file also be modified to restore??|||osql is a command-line utility for executing most any SQL command. As such, you should be able to build a RESTORE command that would do what you want.|||Thanks, but is it not just a matter of replacing the word BACKUP with RESTORE and moving the paths a little around ?
But I see there is special options in the command...|||take a look at that link below, that perhaps will help you:

http://support.microsoft.com/default.aspx?scid=kb;en-us;325003|||There are quite a few options on the SQL restore command. Commands for replacing an existing database, moving the file to a new location, etc. You'd definitly want to find the documentation on the RESTORE command to get it to do exactly what you want.

No comments:

Post a Comment