简体   繁体   English

将.bak文件还原到远程数据库

[英]Restore .bak file to remote database

I have a test.bak file in my local machine. 我的本地计算机上有一个test.bak文件。 I need to restore this file to remote machine's database. 我需要将此文件还原到远程计算机的数据库。 How do I do that? 我怎么做?

When I try this, the remote database throws an error that it is not able to find test.bak on the local filesystem. 当我尝试此操作时,远程数据库将引发错误,它无法在本地文件系统上找到test.bak

Query 询问

RESTORE DATABASE TESTPROJECT 
FROM DISK = 'C:\Program Files\Microsoft SQL Server\MSSQL10_50.ICON3\MSSQL\Backup\test.bak'

Error 错误

Cannot open backup device 'C:\Program Files\Microsoft SQL Server\MSSQL10_50.ICON3\MSSQL\Backup\test.bak'. Operating system error 2(The system cannot find the file specified.).

How can I achieve this? 我该如何实现? I am using Microsoft SQL Server 2008. 我正在使用Microsoft SQL Server 2008。

In the context of this answer - remote refers to your machine, local is the database server. 在此答案的上下文中- remote是指您的计算机, local是数据库服务器。


Restore from local filesystem local文件系统还原

Copy the backup file to the local filesystem, and restore directly from this copy. 将备份文件复制到local文件系统,然后直接从该副本还原。

Prerequisites 先决条件

  • Copy test.bak to C:\\test.bak on the server test.bak复制到服务器上的C:\\test.bak

Syntax 句法

RESTORE DATABASE TESTPROJECT FROM DISK = N'C:\test.bak';

Restore from remote filesystem remote文件系统还原

Alternatively you can restore from the remote backup file using UNC syntax . 或者,您可以使用UNC语法remote备份文件中还原。 I typically don't use this option, but it is useful if there won't be enough disk space on local filesystem for both the backup file and the restored database. 我通常不使用此选项,但是如果local文件系统上没有足够的磁盘空间用于备份文件和已还原的数据库,则该选项很有用。

The success of this option depends on some variables - permissions on the remote filesystem assigned to the database service account, network health, and others. 此选项是否成功取决于某些变量-分配给数据库服务帐户的remote文件系统的权限,网络运行状况等。

Prerequisites 先决条件

  • Remote machine name is remotemachine Remote机器名称是remotemachine
  • Backup located on remote at 'C:\\test.bak' 备份位于'C:\\test.bak' remote位置
  • Database service account has access to the remote administrator share C$ 数据库服务帐户有权访问remote管理员共享C$

Syntax 句法

RESTORE DATABASE TESTPROJECT FROM DISK = N'\\remotemachine\c$\test.bak';

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM