Subscribe to Windows IT Pro
February 05, 2000 12:00 AM

Why can't I backup/restore my SQL Server database to a share on another server?

Windows IT Pro
InstantDoc ID #14025
Rating: (15)

A. A. The reason is that the MSSQLSERVER service is running under a separate set of NT credentials - all services are related to an NT account. It doesn't matter who YOU are logged on as (after all SQL runs quite happily when no-one is logged on locally to the server doesn't it). Therefore your logon account and any mapped drives are irrelevant. It is SQL Server doing the backup, not you. This is the same for backups done via SQL Executive/SQL Agent - they just pass the TSQL to SQL Server to run, so it's still MSSQLSERVER doing the backup/restore.

For this reason the backup gui does not show you mapped drives or allow a UNC path to be typed in. You have to use raw TSQL commands to do the backup.

The default set of NT credentials used by MSSQLSERVER is the Localsystem account. You can check what userid that MSSQLSERVER is running under by looking at control panel/services highlighting MSSQLSERVER and choosing the start-up option.

The Localsystem account has no access to shares on the network as it isn't an authenticated network account. Therefore SQL Server running under this account cannot backup to a normal network share.

So, if you want to backup to a network share you have two choices :-

1. Change the account the MSSQLSERVER service runs under to a user account with the relevant network rights.

or

2. Amend the following registry value on the TARGET server and add the sharename you want to dump to - the share does not then authenticate who is coming in and so a Localsystem account will work. The server service on the target server must be re-started before the change takes effect. Note that this effectively removes ALL security on that share, so you're letting anyone/anything have access. Which is probably not something you want to do with production business data.

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\LanmanServer\Parameters\NullSessionShares


Whichever method you use, you MUST also use a UNC name to reference the file required and not a drive letter.

e.g. (6.5) DUMP DATABASE pubs to DISK='\\server01\share\backupdir\backup.dmp'
(7.0) BACKUP DATABASE pubs to DISK='\\server01\share\backupdir\backup.dmp'


Related Content:

ARTICLE TOOLS

Comments
  • Shrestha
    2 years ago
    Aug 02, 2010

    Hi

    I got the similar problem yesterday and checking the solution here and there. Below is the steps I followed to restore the database

    1. Map the Drive Letter to this location from where you are going to restore the file
    2. Stop MSSQL service from Services on relevant server
    3. Run command prompt under your account by right clicking on the Command Prompt and select user name and password to this domain
    4. Run MSSQL in command prompt mode as follow - this line is from SQL Server(MSSQLSERVER) PROPERTIES --> path to executable
    "C:\\Program Files\\Microsoft SQL Server\\MSSQL.3\\MSSQL\\Binn\\sqlservr.exe" -sMSSQLSERVER
    5. Once above service is running - Restart Ent. Manager and do the restore - you can give the Mapped Drive letter for path and give the name for file.
    6. Verify the .mdf and .ldf file location for this database from Options and click OK - data base will be restored.

    Many Thanks
    Deepak

  • jeremygiaco
    4 years ago
    Jun 25, 2008

    I had the same issue and just identified a solution. I first checked the sql service account (windows login that runs the mssqlserver service). Before reading this article, I added this account to the destination server and granted it access to the share, to no avail. That would have solved the problem for most of the people that had this issue if they hadnt already figured it out....for the people that are aggravated because they still have the issue, try this....
    exec xp_cmdshell 'dir \\\\server\\share\\'

    When i ran that, i receieved error:

    Logon failure: the specified account password has expired.

    Bingo. I wouldnt have known that unless i actually tried to log into the server as the service account. I had only created a mapped drive using the service account credentials to test it, and it did not prompt me to change the password. (the user i created on the destination to match the service account had "change password on next logon" checked. So it was still a valid user with access to the unc path, but i still had an issue.

  • joe
    5 years ago
    Mar 13, 2007

    The suggestions in the OP were cryptic and ultimately didn't work. However, the response about using xp_cmdshell to do a "net use" of the drive worked excellent! I did have to figure out how to *enable* xp_cmdshell but that was pretty easy to find. Great idea and made short work of the problem, as nothing had to be done to the "target" machine at all...

  • Anonymous User
    7 years ago
    Sep 06, 2005

    This problem can be solved if the target machine is a windows 2003 server. You can grant de source sql server "computer" rigths to the share.
    Click to add a user. then click the button "Object Types" and select "Computers". Now you can select the source sql server and grant "Change" permissions to the Share and in the same way you have to grant these rights to the folder (NTFS)

  • Anonymous User
    7 years ago
    Aug 08, 2005

    I was also interested to see this problem already highlighted. I am having a problem backing up a database to a maped drive on another network server (domain controler-DC). My SQL service account is running on a network account which has permissions on the server, which is also a domain controler(DC). I can see shares and drives on the network but not within enterprise manager cant figure out why?

You must log on before posting a comment.

Are you a new visitor? Register Here

advertisement

advertisement

Windows is a trademark of the Microsoft group of companies. Windows IT Pro is used by Penton Media Inc. under license from owner.