Take the 2-minute tour ×
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

Cannot open backup device 'C:\TestPath\test.bak'. Operating system error 3(The system cannot find the path specified.).
RESTORE DATABASE is terminating abnormally.

I don't know why its throwing, I also changed the SQL Server log on from a Network drive to a local connection also. Still its not working. Can some one hint me how to solve this problem?

share|improve this question

migrated from stackoverflow.com Jan 2 '12 at 12:31

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

    
Web or native app? –  Dennis Traub Jan 2 '12 at 10:40
2  
Is the path local to Sql Server or to client PC? –  Oleg Dok Jan 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 Akshinthala Jan 2 '12 at 10:49
    
@OlegDok, path local to client PC –  Sai Kalyan Akshinthala Jan 2 '12 at 10:49
1  
@SaiKalyanAkshinthala: yes, I'm 200% sure - see my answer.... –  marc_s Jan 2 '12 at 10:55
show 2 more comments

2 Answers 2

up vote 4 down vote accepted

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.

share|improve this answer
    
+1, nice answer. Thank you marc_s, i will try changing the name of the drive in my code. Lets see if it works. –  Sai Kalyan Akshinthala Jan 2 '12 at 10:57
add comment

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

share|improve this answer
    
Ok, I agree Mr.Oleg Dok. But how to share the entire drive in my local pc to the sql server running at a remote pc –  Sai Kalyan Akshinthala Jan 2 '12 at 11:18
    
Open "My computer" shortcut, rightclick on drive C - Sharing..., voila –  Oleg Dok Jan 2 '12 at 11:21
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.