首页 > 代码库 > 恢复完整备份文件,差异文件,日志文件

恢复完整备份文件,差异文件,日志文件

----恢复9月6号完全备份
RESTORE DataBase [DB] From  Disk=D:\BackUp\DB_FULL20150906.BAK with NORECOVERY,
Move DB to D:\SQLData\DB_Data.MDF,Move DB_log to D:\SQLData\DB_log.LDF
----恢复9月7号差异备份
RESTORE DATABASE [DB] FROM DISK=D:\BackUp\DB_DIFF20150907.BAK WITH NORECOVERY
--查LSN点,恢复9月7号和8号的日志备份
DECLARE @i INT =7
WHILE @i <= 25
BEGIN
    Restore Log [DB] From  Disk=D:\BackUp\DB_Log20150907.TRN with NORECOVERY ,FILE =@i 
    SET @i =@i +1
END
--8号最后一份回滚
Restore Log [DB] From  Disk=D:\BackUp\DB_Log20150908.TRN with RECOVERY ,FILE =16

--查询备份文件的LSN的语句如下:
RESTORE HEADERONLY FROM DISK = D:\BackUp\DB_DIFF20150907.BAK
RESTORE HEADERONLY FROM DISK = D:\BackUp\DB_Log20150907.TRN

 

恢复完整备份文件,差异文件,日志文件