Exemplo n.º 1
0
 private static IEnumerable <BackupMetadata> NextLogBackup(IEnumerable <BackupMetadata> backups,
                                                           BackupMetadata prevBackup)
 {
     // also gets all the stripes of the next backup
     return(backups.Where(b => b.BackupType == BackupFileTools.BackupType.Log &&
                          prevBackup.LastLsn >= b.FirstLsn && prevBackup.LastLsn + 1 < b.LastLsn));
 }
Exemplo n.º 2
0
        private static IEnumerable <BackupMetadata> MostRecentDiffBackup(IEnumerable <BackupMetadata> backups,
                                                                         BackupMetadata lastFullBackup)
        {
            var diffBackupsOrdered = backups
                                     .Where(b => b.BackupType == BackupFileTools.BackupType.Diff &&
                                            b.DatabaseBackupLsn == lastFullBackup.CheckpointLsn)
                                     .OrderByDescending(b => b.LastLsn).ToList();

            if (!diffBackupsOrdered.Any())
            {
                return(new List <BackupMetadata>());
            }
            var targetLastLsn = diffBackupsOrdered.First().LastLsn;

            // get all the stripes of this backup
            return(diffBackupsOrdered.Where(diffBackup => diffBackup.LastLsn == targetLastLsn));
        }
Exemplo n.º 3
0
        private static bool IsValidFilePath(BackupMetadata meta)
        {
            if (BackupFileTools.IsUrl(meta.PhysicalDeviceName))
            {
                return(true);
            }

            // A quick check before leaning on exceptions
            if (Path.GetInvalidPathChars().Any(meta.PhysicalDeviceName.Contains))
            {
                return(false);
            }

            try {
                // This will throw an argument exception if the path is invalid
                Path.GetFullPath(meta.PhysicalDeviceName);
                // A relative path won't help us much if the destination is another server. It needs to be rooted.
                return(Path.IsPathRooted(meta.PhysicalDeviceName));
            }
            catch (Exception) {
                return(false);
            }
        }
Exemplo n.º 4
0
        private static bool IsValidFilePath(BackupMetadata meta)
        {
            var path = meta.PhysicalDeviceName;

            return(BackupFileTools.IsValidFileUrl(path) || BackupFileTools.IsValidFilePath(path));
        }