非常感谢您的建议 - 它让我感动,但我仍然遇到问题。我现在使用以下命令:
BACKUP DATABASE Prod FILEGROUP='PRIMARY' TO DISK='C:\Temp\Temp\prod.bak' WITH FORMAT;
BACKUP LOG Prod TO DISK='C:\Temp\Temp\prod.trn';
RESTORE DATABASE Test FILEGROUP='PRIMARY' FROM DISK='C:\Temp\Temp\prod.bak' WITH PARTIAL,RECOVERY;
RESTORE LOG Test FROM DISK='C:\Temp\Temp\prod.trn' WITH RECOVERY;
我得到以下回复:
Processed 376 pages for database 'Prod', file 'Prod' on file 1.
Processed 2 pages for database 'Prod', file 'Prod_log' on file 1.
BACKUP DATABASE...FILE=<name> successfully processed 378 pages in 0.082 seconds (36.013 MB/sec).
Processed 7 pages for database 'Prod', file 'Prod_log' on file 6.
BACKUP LOG successfully processed 7 pages in 0.007 seconds (7.254 MB/sec).
Msg 3154, Level 16, State 4, Line 3
The backup set holds a backup of a database other than the existing 'Test' database.
Msg 3013, Level 16, State 1, Line 3
RESTORE DATABASE is terminating abnormally.
Msg 3154, Level 16, State 4, Line 4
The backup set holds a backup of a database other than the existing 'Test' database.
Msg 3013, Level 16, State 1, Line 4
RESTORE LOG is terminating abnormally.
如果我使用WITH REPLACE
而不是WITH PARTIAL
我收到不同的错误消息:
The database cannot be recovered because the log was not restored.
The roll forward start point is now at log sequence number (LSN) 35000000203200001. Additional roll forward past LSN 35000000203200001 is required to complete the restore sequence.
This RESTORE statement successfully performed some actions, but the database could not be brought online because one or more RESTORE steps are needed. Previous messages indicate reasons why recovery cannot occur at this point.
RESTORE DATABASE ... FILE=<name> successfully processed 378 pages in 0.024 seconds (123.046 MB/sec).
Msg 4326, Level 16, State 1, Line 4
The log in this backup set terminates at LSN 35000000092800001, which is too early to apply to the database. A more recent log backup that includes LSN 35000000203200001 can be restored.
Msg 3013, Level 16, State 1, Line 4
RESTORE LOG is terminating abnormally.
如果我WITH NORECOVERY
在数据库还原上使用,该命令会成功,但RESTORE LOG
然后会给我:
RESTORE DATABASE ... FILE=<name> successfully processed 378 pages in 0.032 seconds (92.285 MB/sec).
Msg 4326, Level 16, State 1, Line 4
The log in this backup set terminates at LSN 35000000092800001, which is too early to apply to the database. A more recent log backup that includes LSN 35000000203200001 can be restored.
Msg 3013, Level 16, State 1, Line 4
RESTORE LOG is terminating abnormally.
在任何情况下,目标数据库都停留在“正在恢复”状态。