public fullBackupInfo FindBackupByIdBackup(int idBackup) { backup backup = new backup(); backup = this.context.Backups.Find(idBackup); fullBackupInfo fbi = new fullBackupInfo(backup); return(fbi); }
private void Inc_Backup(fullBackupInfo backup, backup_source source, backup_target target) { string targetPath = target.path; targetPath += @"\inc\"; bool ZIP = backup.format_type == "zip"; targetPath = fileFunc.CheckDirectoriesGetRealName(targetPath, ZIP); if (Directory.GetDirectories(targetPath).Length == 0 && Directory.GetFiles(targetPath).Length == 0) { snapshotFunc.SaveSnapshot(source.path, targetPath); targetPath += AddDate(); if (ZIP) { ZipFile.CreateFromDirectory(source.path, targetPath + ".zip"); } else { fileFunc.Copy(source.path, targetPath); } } else { List <snapshot> rs = snapshotFunc.ReadPreviousSnapshot(targetPath); List <snapshot> cs = snapshotFunc.GetSnapshotList(source.path); snapshotFunc.SaveSnapshot(source.path, targetPath); snapshotFunc.SaveDeleted(rs, cs, targetPath); List <snapshot> difference = snapshotFunc.GetSnapshotDifference(rs, cs); if (ZIP) { string targetPathZ = targetPath + AddDate(); fileFunc.Copy(source.path, targetPathZ, difference); ZipFile.CreateFromDirectory(targetPathZ, targetPathZ + ".zip"); Directory.Delete(targetPathZ, true); } else { fileFunc.Copy(source.path, targetPath + AddDate(), difference); } } fileFunc.DeleteOldBackups(target.path + @"\inc\", ZIP); }
private void DoBackup(fullBackupInfo sbackup) { foreach (backup_source source in sbackup.backup_source) { foreach (backup_target target in sbackup.backup_target) { if (sbackup.backup_type == "full_backup") { Full_Backup(sbackup, source, target); } if (sbackup.backup_type == "diff_backup") { Diff_Backup(sbackup, source, target); } if (sbackup.backup_type == "inc_backup") { Inc_Backup(sbackup, source, target); } } } }
private void Full_Backup(fullBackupInfo backup, backup_source source, backup_target target) { string targetPath = target.path; targetPath += @"\full\"; bool ZIP = backup.format_type == "zip"; fileFunc.CheckParentDirectory(targetPath, ZIP); if (ZIP) { ZipFile.CreateFromDirectory(source.path, targetPath + AddDate() + ".zip"); } else { fileFunc.Copy(source.path, targetPath + AddDate()); } fileFunc.DeleteOldBackups(target.path + @"\full\", ZIP); HttpRequests.PostJobHistory(backup.id, DateTime.Now, true); }