Restore database backup over the network

前端 未结 10 1199
不思量自难忘°
不思量自难忘° 2021-01-30 03:58

How do you restore a database backup using SQL Server 2005 over the network? I recall doing this before but there was something odd about the way you had to do it.

相关标签:
10条回答
  • 2021-01-30 04:26

    I've had to do this a few times, and there are only two options that I know of. Copy the file locally to the SQL Server, or on the SQL server create a mapped network drive to the share that contains the backup file.

    0 讨论(0)
  • 2021-01-30 04:27

    Make sure that the user running your SQL services in "Services.msc" is an active directory "Domain User" this will fix the issue.

    0 讨论(0)
  • 2021-01-30 04:29

    You have few options to use a network file as a backup source

    1. Map network drive/path, hosting file, under SAME user as MS-SQL Server.
    2. Use xp_cmdshell extended stored procedure to map network drive from inside of MS SQL (such way, command shell will have the same privilegies as the user account running SSMS)
    -- allow changes to advanced options 
    EXEC sp_configure 'show advanced options', 1
    GO
    -- Update currently configured values for advanced options.
    RECONFIGURE
    GO
    -- To enable xp_cmdshell
    EXEC sp_configure 'xp_cmdshell', 1
    GO
    -- Update currently configured values for advanced options.
    RECONFIGURE
    GO
    EXEC xp_cmdshell 'NET USE Z: \\Srv\Path password1 /USER:Domain\UserName'
    

    Afterwards drive Z: will be visible in Server Managment studio, or just

    RESTORE DATABASE DataBaseNameHere FROM DISK = 'Z:\BackNameHere.BAK'
    GO
    
    0 讨论(0)
  • 2021-01-30 04:39

    The database is often running as a service under an account with no network access. If this is the case, then you wouldn't be able to restore directly over the network. Either the backup needs to be copied to the local machine or the database service needs to run as a user with the proper network access.

    0 讨论(0)
  • 2021-01-30 04:46

    Also, you need to make sure that the SQL Server Service is running as a user that has network access - and permissions to the share where the backup file lives. 'Local System' won't have permissions to access the network.

    0 讨论(0)
  • 2021-01-30 04:47

    As a side note, if you happen to be running SQL on a Virtual Machine it's often less hassle to just temporarily set up a new drive on the VM with enough space to copy your backup files to, do the restore from that new local copy, and then delete the temp drive.

    This can be useful if stopping/starting the SQL service to change it's account is an issue.

    0 讨论(0)
提交回复
热议问题