public Backup(string backup) { if (backup == null) throw new ArgumentNullException("backup"); BackupDate = backup; Entry = BackupEngine.Instance.Grf.FileTable[GrfPath.Combine(BackupDate, BackupEngine.InfoName)]; Info = new BackupInfo(new ReadonlyConfigAsker(Entry.GetDecompressedData())); }
public void Start(string dbPath) { if (!SdeAppConfiguration.BackupsManagerState || _isCrashed) return; if (dbPath == null) throw new ArgumentNullException("dbPath"); _currentId++; _validateOpened(); BackupInfo info = new BackupInfo(new TextConfigAsker(new byte[] {})); info.DestinationPath = Path.GetDirectoryName(dbPath); if (!_paths.ContainsKey(_currentId)) { _paths[_currentId] = _getGrfPath(); } _grf.Commands.AddFileAbsolute(GrfPath.Combine(_paths[_currentId], InfoName), info.GetData()); List<string> paths = GetBackupFiles().OrderBy(long.Parse).ToList(); while (paths.Count > MaximumNumberOfBackups) { RemoveBackupDelayed(paths[0]); paths.RemoveAt(0); } _isStarted = true; }
public void Restore(string backup) { if (backup == null) { throw new ArgumentNullException("backup"); } _validateOpened(); BackupInfo info = new BackupInfo(new ReadonlyConfigAsker(_grf.FileTable[GrfPath.Combine(backup, InfoName)].GetDecompressedData())); if (!Directory.Exists(info.DestinationPath)) { Directory.CreateDirectory(info.DestinationPath); } foreach (FileEntry entry in _grf.FileTable.EntriesInDirectory(backup, SearchOption.AllDirectories)) { if (entry.RelativePath.EndsWith(InfoName)) { continue; } entry.ExtractFromAbsolute(GrfPath.Combine(info.DestinationPath, entry.RelativePath.ReplaceFirst(backup + "\\", ""))); } _grf.Close(); }
public void Start(string dbPath) { if (!SdeAppConfiguration.BackupsManagerState || _isCrashed) { return; } if (dbPath == null) { throw new ArgumentNullException("dbPath"); } _currentId++; _validateOpened(); BackupInfo info = new BackupInfo(new TextConfigAsker(new byte[] {})); info.DestinationPath = Path.GetDirectoryName(dbPath); if (!_paths.ContainsKey(_currentId)) { _paths[_currentId] = _getGrfPath(); } _grf.Commands.AddFileAbsolute(GrfPath.Combine(_paths[_currentId], InfoName), info.GetData()); List <string> paths = GetBackupFiles().OrderBy(long.Parse).ToList(); while (paths.Count > MaximumNumberOfBackups) { RemoveBackupDelayed(paths[0]); paths.RemoveAt(0); } _isStarted = true; }
public void Restore(string backup) { if (backup == null) throw new ArgumentNullException("backup"); _validateOpened(); BackupInfo info = new BackupInfo(new ReadonlyConfigAsker(_grf.FileTable[GrfPath.Combine(backup, InfoName)].GetDecompressedData())); if (!Directory.Exists(info.DestinationPath)) { Directory.CreateDirectory(info.DestinationPath); } foreach (FileEntry entry in _grf.FileTable.EntriesInDirectory(backup, SearchOption.AllDirectories)) { if (entry.RelativePath.EndsWith(InfoName)) continue; entry.ExtractFromAbsolute(GrfPath.Combine(info.DestinationPath, entry.RelativePath.ReplaceFirst(backup + "\\", ""))); } _grf.Close(); }