Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

I am trying to restore some database backup file into the same database. The .bak file is creating problem always. When I select the .bak file from a network drive like "\\TestPC\ShareFolder\test.bak" then its working correctly.

But the same .bak file if I select from a local drive by copying it to my pc, say C:\TestPath\test.bak then for every time its throwing a exception saying

This question came from our site for professional and enthusiast programmers.

Web or native app?
–
Dennis TraubJan 2 '12 at 10:40

2

Is the path local to Sql Server or to client PC?
–
Oleg DokJan 2 '12 at 10:46

@marc_s, actually the sql server is there in another pc and I have written one C# application to restore a *.bak file. Here if the .bak file is in my pc then its throwing the above exception, but if I select the same .bak file from any network drive its working fine.
–
Sai Kalyan Kumar AkshinthalaJan 2 '12 at 10:49

2 Answers
2

If you want to restore a *.bak file onto a machine e.g. TESTSERVER, then that *.bak file needs to be

on a local drive of TESTSERVER, or:

on a share in the network that TESTSERVER can reach (a "public" share)

So if you have the *.bak file on your local PC MyPC, you can try to do a restore from \\MyPC\C$\ShareFolder\Backupfile.bak and this might or might not work.

But you cannot use C:\ShareFolder\Backupfile.bak since that will go to the server's C:\ drive and look for that file - and thus you get the error message and it cannot be found.

After all: your SQL Server instance is running on TESTSERVER - so if that process there executes a restore from the C:\ drive, that'll be the C:\ drive on that server machine - not your local PC! If that server process on TESTSERVER can reach your machine, then you might use the UNC path notation to your local disk - so that might work.

So, you placed the backup file locally and then Sql Server have to read it thru or \\YourPC\c$\TestPath\test.bak (because sql server knows nothing about YOUR disk C - which is possible only in domain network and you gave to grant local admin privileges to account, the sql server runs under, or you have to share your TestPath folder and grant the sql server's account access to it

BUT

If there is a Windows-domain environment, then run sql server under LocalSystem and set to the share permission to access to user DOMAINNAME\SQLSERVERPC$ where SQLSERVERPC is the name of machinesql server running on

If there is no any domain authentication available, then you need to open Guest auth to share on backup-file machine