如何在同一服务器上将数据库备份和恢复为副本?
我有一个 SQL2005 Express 数据库,我想在同一实例上创建它的副本。您如何使用脚本来做到这一点?
我已经有一个用于生成备份的脚本,但恢复失败...
错误:
消息 3234,级别 16,状态 2,第 2 行 逻辑文件“MyDB_data”不是一部分 数据库“MyDB_Test”的。使用恢复 FILELISTONLY 列出逻辑文件 名字。
消息 3013,16 级,状态 1, 第 2 行 RESTORE DATABASE 正在终止 异常。
解决方案:
RESTORE DATABASE [MyDB_Test]
FROM DISK = 'C:\temp\SQL\MyDB.bak'
WITH
MOVE 'MyDB' TO 'C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\DATA\MyDB_Test.mdf'
, MOVE 'MyDB_log' TO 'C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\DATA\MyDB_Test_log.ldf'
, REPLACE;
原因:
我在第一次尝试中没有正确识别逻辑路径。
I have a SQL2005 Express database that I would like to create a copy of on the same instance. How do you go about doing this with a script?
I already have a script for generating the backup, but the restore is failing...
THE ERROR:
Msg 3234, Level 16, State 2, Line 2
Logical file 'MyDB_data' is not part
of database 'MyDB_Test'. Use RESTORE
FILELISTONLY to list the logical file
names.
Msg 3013, Level 16, State 1,
Line 2 RESTORE DATABASE is terminating
abnormally.
THE RESOLUTION:
RESTORE DATABASE [MyDB_Test]
FROM DISK = 'C:\temp\SQL\MyDB.bak'
WITH
MOVE 'MyDB' TO 'C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\DATA\MyDB_Test.mdf'
, MOVE 'MyDB_log' TO 'C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\DATA\MyDB_Test_log.ldf'
, REPLACE;
THE REASON:
I did not identify the logical path correctly in my first attempt.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
RESTORE FILELISTONLY
是一条信息性命令,不需要执行恢复。用户可以使用它来找出数据文件的逻辑名称,这些逻辑名称可以与 MOVE 命令一起使用以将数据库恢复到新位置。根据错误消息的建议,您需要使用 RESTORE FILELISTONLY 来查看数据库的逻辑名称是什么。您的恢复命令有这些错误。
这是您需要执行的操作的示例:
RESTORE FILELISTONLY
is an informational command and is not required to perform a restore. A user can use this to figure out what the logical names are for the data files, that can be used with theMOVE
commands to restore the database to a new location.As suggested by the error message you need to use
RESTORE FILELISTONLY
to see what the logical names for the database are. Your restore command has these wrong.Here is a working example of what you need to do:
如何:将数据库还原到新位置和名称 (Transact-SQL)
How to: Restore a Database to a New Location and Name (Transact-SQL)
以下是一些替代方案:
数据库恢复(从 .BAK)软件::
1) SqlRestoreSetup
2) Apex SQL 恢复
Here are some alternatives:
Database restore (from .BAK) softwares::
1) SqlRestoreSetup
2) Apex SQL Restore