Database-SQL-Server-04-SQL Server-Restore
通过备份恢复
使用完全备份恢复
<DatabaseName> <FullBackupFilePath> 需要替换为对应值再执行
RESTORE DATABASE <DatabaseName>
FROM
DISK = N'<FullBackupFilePath>'
WITH
FILE = 1
使用完全备份+差异备份恢复
注意:差异备份只需要最新的一个差异备份就好,不需要上一次完整备份至最新之间的所有差异备份
<DatabaseName> <FullBackupFilePath> <DiffBackupFilePath> 需要替换为对应值再执行
RESTORE DATABASE <DatabaseName>
FROM
DISK = N'<FullBackupFilePath>'
WITH
FILE = 1,
NORECOVERY -- 需要先以非恢复模式恢复完整备份,否则差异备份无法恢复,即下面sql执行会失败
RESTORE DATABASE <DatabaseName>
FROM
DISK = N'<DiffBackupFilePath>'
WITH
FILE = 1
FAQ
Q1: Msg 3117, Level 16, State 1, Line 7 The log or differential backup cannot be restored because no files are ready to rollforward. Msg 3013, Level 16, State 1, Line 7 RESTORE DATABASE is terminating abnormally.
A1: 检查还原完整备份的脚本是否有NORECOVERY 选项