标签:
原文:SQL Server差异备份的备份/还原原理记住一点:差异备份是基于最后一次完整备份的差异,而不是基于最后一次差异的差异
FirstLSN
LastLSN
CheckpointLSN
DatabaseBackupLSN
DifferentialBaseLSN
BOOTPAGE里只有DifferentialBaseLSN有值
总体来说,差异备份文件里会存放
FirstLSN
LastLSN
CheckpointLSN
DatabaseBackupLSN
DifferentialBaseLSN
(2)活动日志
(3)差异页面
DifferentialBaseLSN作用:要还原差异备份先要还原一个完整备份,使用NORECOVERY选项,再还原差异备份,当还原差异备份的时候,数据库根据差异备份文件里的DifferentialBaseLSN的值跟
数据库BOOTPAGE保存的DifferentialBaseLSN的值进行比较,如果对不上,那么这个差异备份不能还原,另外一个是作为差异备份还原的基准LSN,差异备份文件里的CheckpointLSN如果小于DifferentialBaseLSN
那么也是没有必要还原
--脚本 SELECT DB_ID(‘sss‘) DBCC fileheader(16) BACKUP DATABASE [sss] TO DISK=‘c:\sss_full.bak‘ RESTORE FILELISTONLY FROM DISK =‘c:\sss_full.bak‘ RESTORE HEADERONLY FROM DISK =‘c:\sss_full.bak‘ 1585000000012200042 --backuplsn 1686000000056400078 --ckpt lsn 1686000000060800001 --last lsn CREATE TABLE tessssss(id INT) go INSERT tessssss SELECT 1 UNION ALL SELECT 2 BACKUP DATABASE [sss] TO DISK=‘c:\sss_diff.bak‘ WITH Differential RESTORE HEADERONLY FROM DISK =‘c:\sss_diff.bak‘ 1686000000056400078 --backuplsn 1686000000056400078 --diff lsn 1686000000065400151 --ckpt lsn 1686000000071800001 --last lsn INSERT tessssss SELECT 3 UNION ALL SELECT 4 BACKUP DATABASE [sss] TO DISK=‘c:\sss_diff2.bak‘ WITH Differential RESTORE HEADERONLY FROM DISK =‘c:\sss_diff2.bak‘ 1686000000056400078 --backuplsn 1686000000056400078 --diff lsn 1686000000071900004 --ckpt lsn 1686000000072300001 --last lsn --FirstLSN --LastLSN --CheckpointLSN --DatabaseBackupLSN --DifferentialBaseLSN
您真的理解了SQLSERVER的日志链了吗?
http://www.cnblogs.com/lyhabc/p/3460272.html
标签:
原文地址:http://www.cnblogs.com/lonelyxmas/p/4774809.html