时间:2021-07-01 10:21:17 帮助过:6人阅读
FirstLSN
LastLSN
CheckpointLSN
DatabaseBackupLSN
DifferentialBaseLSN
BOOTPAGE里只有DifferentialBaseLSN有值
总体来说,差异备份文件里会存放
(1)下面的LSN值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
MySQL的xtrabackup备份工具的原理其实也是差不多,读取页面,根据CheckpointLSN和页面的LSN比较进行备份和还原 所以LSN在数据库的备份还原里面起着重要作用 对于最后一个LSN可以参考:
您真的理解了SQLSERVER的日志链了吗?
http://www.cnblogs.com/lyhabc/p/3460272.html
SQL Server差异备份的备份/还原原理
标签: