public void BackupHeaders_ShouldReturnFullBackupHeader() { IOptions <BackupStoreSettings> options = Options.Create(new BackupStoreSettings { BackupFileExtensions = { "BAK" }, BackupPaths = { Path.Combine(AppContext.BaseDirectory, "Bak") } }); var store = new BackupStore(GetServer(), options); List <BackupHeader> backupHeaders = store.BackupHeaders; backupHeaders.Should().HaveCount(6); BackupHeader info = backupHeaders[0]; info.BackupType.Should().Be(BackupType.Differential); info.DatabaseName.Should().Be("Test"); info.BackupName.Should().Be("Test-Diff Database Backup"); info.StartDate.Should().Be(new DateTime(2020, 7, 27, 9, 32, 5)); info.BackupFinishDate.Should().Be(new DateTime(2020, 7, 27, 9, 32, 5)); info.FirstLSN.Should().Be(37000000102900001M); info.LastLSN.Should().Be(37000000103200001M); info.Position.Should().Be(1); info.SoftwareVersionMajor.Should().Be(15); info.Values.Count.Should().Be(56); info = backupHeaders[1]; info.BackupType.Should().Be(BackupType.Full); info.DatabaseName.Should().Be("Test"); info.BackupName.Should().Be("Test-Full Database Backup"); info.StartDate.Should().Be(new DateTime(2020, 7, 25, 12, 45, 00)); info.BackupFinishDate.Should().Be(new DateTime(2020, 7, 25, 12, 45, 00)); info.FirstLSN.Should().Be(37000000091400001M); info.LastLSN.Should().Be(37000000091700001M); info.Position.Should().Be(1); info.SoftwareVersionMajor.Should().Be(15); info.Values.Count.Should().Be(56); info = backupHeaders[2]; info.BackupType.Should().Be(BackupType.Full); info.DatabaseName.Should().Be("Test"); info.BackupName.Should().Be("Test-Full Database Backup"); info.StartDate.Should().Be(new DateTime(2020, 8, 3, 16, 15, 53)); info.BackupFinishDate.Should().Be(new DateTime(2020, 8, 3, 16, 15, 53)); info.FirstLSN.Should().Be(37000000136800001M); info.LastLSN.Should().Be(37000000137100001M); info.Position.Should().Be(1); info.SoftwareVersionMajor.Should().Be(15); info.Values.Count.Should().Be(56); info = backupHeaders[3]; info.BackupType.Should().Be(BackupType.Log); info.DatabaseName.Should().Be("Test"); info.BackupName.Should().Be("Test-Log Database Backup"); info.StartDate.Should().Be(new DateTime(2020, 8, 3, 12, 19, 56)); info.BackupFinishDate.Should().Be(new DateTime(2020, 8, 3, 12, 19, 56)); info.FirstLSN.Should().Be(37000000019700001M); info.LastLSN.Should().Be(37000000128700001M); info.Position.Should().Be(1); info.SoftwareVersionMajor.Should().Be(15); info.Values.Count.Should().Be(56); }
public void GetLatestFull_ReturnFull2() { IOptions <BackupStoreSettings> options = Options.Create(new BackupStoreSettings { BackupFileExtensions = { "BAK" }, BackupPaths = { Path.Combine(AppContext.BaseDirectory, "Bak") } }); var store = new BackupStore(GetServer(), new FileSystem(), options); BackupHeader info = store.GetLatestFull("DESKTOP-NVACFK6", "Test"); info.Should().NotBeNull(); info.BackupType.Should().Be(BackupType.Full); info.DatabaseName.Should().Be("Test"); info.BackupName.Should().Be("Test-Full Database Backup"); info.StartDate.Should().Be(new DateTime(2020, 8, 3, 16, 15, 53)); info.FinishDate.Should().Be(new DateTime(2020, 8, 3, 16, 15, 53)); info.FirstLSN.Should().Be(37000000136800001M); info.LastLSN.Should().Be(37000000137100001M); info.Position.Should().Be(1); info.SoftwareVersionMajor.Should().Be(15); info.Values.Count.Should().Be(56); }
public DlcBin(Stream stream) { Key = new u8[Util.AesKeySize]; Bk = BackupHeader.Create(stream); stream.Position = Util.RoundUp(stream.Position, 0x40); TMD = TMD.Create(stream); stream.Position = Util.RoundUp(stream.Position, 0x40); u16 index = u16.MaxValue; for (int i = 0; i < Bk.ContentIndex.Length; i++) { if (Bk.ContentIndex[i] != 0) { index = (u16)(i * 8); for (int k = 1; k < 8; k++) { if ((Bk.ContentIndex[i] & (1 << k)) != 0) { index += (u16)k; } } } } if (index != ushort.MaxValue) { Content = TMD.Contents[index]; } RawData = new Substream(stream, stream.Position, Content != null ? Util.RoundUp(Content.Size, 0x40) : (stream.Length - stream.Position)); if (Content != null) { byte[] iv = new byte[0x10]; BigEndianConverter.GetBytes(Content.Index).CopyTo(iv, 0); Data = new Substream(new AesStream(RawData, Key, iv), 0, Content.Size); } }
public void GetLatestDiffWithFull_ReturnFull1Diff2() { IOptions <BackupStoreSettings> options = Options.Create(new BackupStoreSettings { BackupFileExtensions = { "BAK" }, BackupPaths = { Path.Combine(AppContext.BaseDirectory, "Bak") } }); var store = new BackupStore(GetServer(), new FileSystem(), options); IEnumerable <BackupHeader> infos = store.GetLatestDiffWithFull("DESKTOP-NVACFK6", "Test"); infos.Should().HaveCount(2); BackupHeader info = infos.First(); info.Should().NotBeNull(); info.BackupType.Should().Be(BackupType.Full); info.DatabaseName.Should().Be("Test"); info.BackupName.Should().Be("Test-Full Database Backup"); info.StartDate.Should().Be(new DateTime(2020, 7, 25, 12, 45, 00)); info.FinishDate.Should().Be(new DateTime(2020, 7, 25, 12, 45, 00)); info.FirstLSN.Should().Be(37000000091400001M); info.LastLSN.Should().Be(37000000091700001M); info.Position.Should().Be(1); info.SoftwareVersionMajor.Should().Be(15); info.Values.Count.Should().Be(56); info = infos.Last(); info.Should().NotBeNull(); info.BackupType.Should().Be(BackupType.Differential); info.DatabaseName.Should().Be("Test"); info.BackupName.Should().Be("Test-Diff Database Backup"); info.StartDate.Should().Be(new DateTime(2020, 8, 3, 14, 47, 32)); info.FinishDate.Should().Be(new DateTime(2020, 8, 3, 14, 47, 32)); info.FirstLSN.Should().Be(37000000133600001M); info.LastLSN.Should().Be(37000000133900001M); info.Position.Should().Be(2); info.SoftwareVersionMajor.Should().Be(15); info.Values.Count.Should().Be(56); }
public DlcBin() { Bk = new BackupHeader(); TMD = new TMD(); Key = new u8[Util.AesKeySize]; }