如何将我的备份恢复到不同的数据库?
How to restore my backup to a different database?
我有一个备份,我希望它能将它恢复到一个新的
数据库 Wss_Content3
备份文件是 Wss_Content 数据库的备份。
当我运行以下代码时:
USE Master;
GO
RESTORE DATABASE Wss_Content3 FROM DISK = 'f:\Fill_Wss_Content.bak'
WITH
MOVE 'Wss_Content3' TO 'E:\MSSQL\MSSQL11.SHP2013PROD\MSSQL\Data\Wss_Content3.mdf',
---------------------------------------^^^^^
MOVE 'Wss_Content3_log' TO 'F:\MSSQL\MSSQL11.SHP2013PROD\MSSQL\Data\Wss_Content3_log.ldf';
我得到:
Msg 1834, Level 16, State 1, Line 3 The file
'E:\MSSQL\MSSQL11.SHP2013PROD\MSSQL\Data\WSS_Content.mdf' cannot be
overwritten. It is being used by database 'WSS_Content'. Msg 3156,
Level 16, State 4, Line 3 File 'WSS_Content' cannot be restored to
'E:\MSSQL\MSSQL11.SHP2013PROD\MSSQL\Data\WSS_Content.mdf'. Use WITH
MOVE to identify a valid location for the file. Msg 1834, Level 16,
State 1, Line 3 The file
'F:\MSSQL\MSSQL11.SHP2013PROD\MSSQL\Data\WSS_Content_log.ldf' cannot
be overwritten. It is being used by database 'WSS_Content'. Msg 3156,
Level 16, State 4, Line 3 File 'WSS_Content_log' cannot be restored to
'F:\MSSQL\MSSQL11.SHP2013PROD\MSSQL\Data\WSS_Content_log.ldf'. Use
WITH MOVE to identify a valid location for the file. Msg 3119, Level
16, State 1, Line 3 Problems were identified while planning for the
RESTORE statement. Previous messages provide details. Msg 3013, Level
16, State 1, Line 3 RESTORE DATABASE is terminating abnormally.
这就像在数据库 Wss_Content 上恢复,但我想在新数据库 Wss_Content3 上恢复。
我该怎么做?
编辑:
有:
USE Master;
GO
RESTORE DATABASE Wss_Content3 FROM DISK = 'f:\Fill_Wss_Content.bak'
WITH
MOVE 'Wss_Content' TO 'E:\MSSQL\MSSQL11.SHP2013PROD\MSSQL\Data\Wss_Content3.mdf',
---------------------------------------^^^^^
MOVE 'Wss_Content_log' TO 'F:\MSSQL\MSSQL11.SHP2013PROD\MSSQL\Data\Wss_Content3_log.ldf';
我得到:
Msg 3154, Level 16, State 4, Line 2
The backup set holds a backup of a database other than the existing 'Wss_Content3' database.
Msg 3013, Level 16, State 1, Line 2
RESTORE DATABASE is terminating abnormally.
EDIT2:
USE Master;
GO
RESTORE FILELISTONLY FROM DISK = 'f:\Fill_Wss_Content.bak'
WSS_Content E:\MSSQL\MSSQL11.SHP2013PROD\MSSQL\Data\WSS_Content.mdf D PRIMARY 163158360064 35184372080640 1 0 0 140B6DD4-DCA0-4FD8-BA65-59390D5FC3B5 0 0 162484191232 512 1 NULL 133075000000938400215 F50C4B9C-B575-4158-B5D6-F44B92FE0380 0 1 NULL
WSS_Content_log F:\MSSQL\MSSQL11.SHP2013PROD\MSSQL\Data\WSS_Content_log.ldf L NULL 22918791168 2199023255552 2 0 0 C83B63C2-B68E-4101-A52B-07EFC08446D7 0 0 0 512 0 NULL 0 00000000-0000-0000-0000-000000000000 0 1 NULL
编辑 3:
我已经试过了(使用 Wss_Content5.mdf 和 Wss_Content5_log.ldf
) 不存在:
RESTORE DATABASE Wss_Content3 FROM DISK = 'f:\Fill_Wss_Content.bak'
WITH
MOVE 'Wss_Content' TO 'E:\MSSQL\MSSQL11.SHP2013PROD\MSSQL\Data\Wss_Content5.mdf',
---------------------------------------^^^^^
MOVE 'Wss_Content_log' TO 'F:\MSSQL\MSSQL11.SHP2013PROD\MSSQL\Data\Wss_Content5_log.ldf
不幸的是我得到了这个错误:
Msg 3154, Level 16, State 4, Line 5
The backup set holds a backup of a database other than the existing 'Wss_Content3' database.
Msg 3013, Level 16, State 1, Line 5
RESTORE DATABASE is terminating abnormally.
您需要使用以下选项:
WITH REPLACE
如果您使用 SQL Management Studio 中的向导而不是命令行来恢复数据库,则需要检查相应的选项:"Overwrite the existing database (WITH REPLACE)"
我有一个备份,我希望它能将它恢复到一个新的 数据库 Wss_Content3 备份文件是 Wss_Content 数据库的备份。
当我运行以下代码时:
USE Master;
GO
RESTORE DATABASE Wss_Content3 FROM DISK = 'f:\Fill_Wss_Content.bak'
WITH
MOVE 'Wss_Content3' TO 'E:\MSSQL\MSSQL11.SHP2013PROD\MSSQL\Data\Wss_Content3.mdf',
---------------------------------------^^^^^
MOVE 'Wss_Content3_log' TO 'F:\MSSQL\MSSQL11.SHP2013PROD\MSSQL\Data\Wss_Content3_log.ldf';
我得到:
Msg 1834, Level 16, State 1, Line 3 The file 'E:\MSSQL\MSSQL11.SHP2013PROD\MSSQL\Data\WSS_Content.mdf' cannot be overwritten. It is being used by database 'WSS_Content'. Msg 3156, Level 16, State 4, Line 3 File 'WSS_Content' cannot be restored to 'E:\MSSQL\MSSQL11.SHP2013PROD\MSSQL\Data\WSS_Content.mdf'. Use WITH MOVE to identify a valid location for the file. Msg 1834, Level 16, State 1, Line 3 The file 'F:\MSSQL\MSSQL11.SHP2013PROD\MSSQL\Data\WSS_Content_log.ldf' cannot be overwritten. It is being used by database 'WSS_Content'. Msg 3156, Level 16, State 4, Line 3 File 'WSS_Content_log' cannot be restored to 'F:\MSSQL\MSSQL11.SHP2013PROD\MSSQL\Data\WSS_Content_log.ldf'. Use WITH MOVE to identify a valid location for the file. Msg 3119, Level 16, State 1, Line 3 Problems were identified while planning for the RESTORE statement. Previous messages provide details. Msg 3013, Level 16, State 1, Line 3 RESTORE DATABASE is terminating abnormally.
这就像在数据库 Wss_Content 上恢复,但我想在新数据库 Wss_Content3 上恢复。
我该怎么做?
编辑: 有:
USE Master;
GO
RESTORE DATABASE Wss_Content3 FROM DISK = 'f:\Fill_Wss_Content.bak'
WITH
MOVE 'Wss_Content' TO 'E:\MSSQL\MSSQL11.SHP2013PROD\MSSQL\Data\Wss_Content3.mdf',
---------------------------------------^^^^^
MOVE 'Wss_Content_log' TO 'F:\MSSQL\MSSQL11.SHP2013PROD\MSSQL\Data\Wss_Content3_log.ldf';
我得到:
Msg 3154, Level 16, State 4, Line 2
The backup set holds a backup of a database other than the existing 'Wss_Content3' database.
Msg 3013, Level 16, State 1, Line 2
RESTORE DATABASE is terminating abnormally.
EDIT2:
USE Master;
GO
RESTORE FILELISTONLY FROM DISK = 'f:\Fill_Wss_Content.bak'
WSS_Content E:\MSSQL\MSSQL11.SHP2013PROD\MSSQL\Data\WSS_Content.mdf D PRIMARY 163158360064 35184372080640 1 0 0 140B6DD4-DCA0-4FD8-BA65-59390D5FC3B5 0 0 162484191232 512 1 NULL 133075000000938400215 F50C4B9C-B575-4158-B5D6-F44B92FE0380 0 1 NULL
WSS_Content_log F:\MSSQL\MSSQL11.SHP2013PROD\MSSQL\Data\WSS_Content_log.ldf L NULL 22918791168 2199023255552 2 0 0 C83B63C2-B68E-4101-A52B-07EFC08446D7 0 0 0 512 0 NULL 0 00000000-0000-0000-0000-000000000000 0 1 NULL
编辑 3: 我已经试过了(使用 Wss_Content5.mdf 和 Wss_Content5_log.ldf ) 不存在:
RESTORE DATABASE Wss_Content3 FROM DISK = 'f:\Fill_Wss_Content.bak'
WITH
MOVE 'Wss_Content' TO 'E:\MSSQL\MSSQL11.SHP2013PROD\MSSQL\Data\Wss_Content5.mdf',
---------------------------------------^^^^^
MOVE 'Wss_Content_log' TO 'F:\MSSQL\MSSQL11.SHP2013PROD\MSSQL\Data\Wss_Content5_log.ldf
不幸的是我得到了这个错误:
Msg 3154, Level 16, State 4, Line 5
The backup set holds a backup of a database other than the existing 'Wss_Content3' database.
Msg 3013, Level 16, State 1, Line 5
RESTORE DATABASE is terminating abnormally.
您需要使用以下选项:
WITH REPLACE
如果您使用 SQL Management Studio 中的向导而不是命令行来恢复数据库,则需要检查相应的选项:"Overwrite the existing database (WITH REPLACE)"