如何从 .bak 文件恢复数据库? [英] How to restore a database from a .bak file?
问题描述
我的 .bak
文件是另一个本地服务器.
My .bak
file is the other the local server.
我尝试了太多不同的脚本,但都没有成功.
I tried too many different script but unable to successes.
我试过的语法是
RESTORE FILELISTONLY FROM DISK='D:\ERPNewtesting-12022014.bak'
从上面的查询中获取逻辑名并在下面的查询中使用
Get the Logicalname from above query and use in below query
RESTORE DATABASE Test FROM DISK='ERPNewtesting-12022014.bak'
WITH
MOVE 'ERPAgrotechBeta' TO 'D:\Pragnesh\Test.mdf',
MOVE 'ERPAgrotechBeta_log' TO 'D:\Pragnesh\Test_log.ldf',
REPLACE,
STATS=10
执行上述查询后,会生成以下错误.
After executing above query below error is generate.
消息 3201,级别 16,状态 2,第 3 行
无法打开备份设备C:\Program Files (x86)\Microsoft SQL Server\MSSQL11.MSSQLSERVER\MSSQL\Backup\ERPNewtesting-12022014.bak".操作系统错误 2(系统找不到指定的文件.).
消息 3013,级别 16,状态 1,第 3 行
RESTORE DATABASE 异常终止.
Msg 3201, Level 16, State 2, Line 3
Cannot open backup device 'C:\Program Files (x86)\Microsoft SQL Server\MSSQL11.MSSQLSERVER\MSSQL\Backup\ERPNewtesting-12022014.bak'. Operating system error 2(The system cannot find the file specified.).
Msg 3013, Level 16, State 1, Line 3
RESTORE DATABASE is terminating abnormally.
请以这种方式帮助我
推荐答案
听起来您已经在一台服务器上备份了一个数据库,而您想将其恢复到另一台服务器上.这是正确的吗?
It sounds like you have backed up a db on one server, and you want to restore it to another server. Is this correct?
您的备份文件 D:\ERPNewtesting-12022014.bak
在服务器 A 上,对吗?它需要可供在服务器 B 上运行 SQL Server 服务的帐户访问.我想到了几个快速选项:
Your backup file D:\ERPNewtesting-12022014.bak
is on server A, right? It needs to be accessible to the account running the SQL Server service on server B. A few quick options come to mind:
- 在服务器 A 上创建一个共享,将备份文件移动到相应的共享文件夹中.
- 将备份文件移动到现有的 UNC 路径.
- 将备份文件移动到服务器 B.
然后继续还原.如果您选择选项 1 或 2,它将是这样的:
Then proceed with the restore. If you chose option 1 or 2, it will be something like this:
RESTORE DATABASE Test
FROM DISK='\\SomeServer\Shared Folder\ERPNewtesting-12022014.bak'
WITH
MOVE 'ERPAgrotechBeta' TO 'D:\Pragnesh\Test.mdf',
MOVE 'ERPAgrotechBeta_log' TO 'D:\Pragnesh\Test_log.ldf',
REPLACE,
STATS=10
如果您选择选项 3,它将如下所示:
If you chose option 3, it will look something like this:
RESTORE DATABASE Test
FROM DISK='D:\Path on Server B\ERPNewtesting-12022014.bak'
WITH
MOVE 'ERPAgrotechBeta' TO 'D:\Pragnesh\Test.mdf',
MOVE 'ERPAgrotechBeta_log' TO 'D:\Pragnesh\Test_log.ldf',
REPLACE,
STATS=10
这篇关于如何从 .bak 文件恢复数据库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!