Exemple #1
0
        /// <summary>
        ///     Convenience factory method creating the recommended Month-Day-day scheme convention.
        /// </summary>
        /// <remarks>
        ///     - backups in calendar monthly folders
        ///     <br />
        ///     - every month starts with single full backup in the month, file name 'yyyy-MM-MMM-{db name}-full.bak'
        ///     <br />
        ///     - every day starts with single diff backup, file name 'yyyy-MM-MMM-dd-{db name}-diff.bak'
        ///     <br />
        ///     - during day all log backups are written to 'yyyy-MM-MMM-{db name}-log.trn'
        /// </remarks>
        /// <returns></returns>
        public static BackupFileNamingConvention CreateDefaultMonthDayDayConvention()
        {
            var result = new BackupFileNamingConvention();

            var fullBackupFileNameParser = new BackupFilesystemObjectNameParser(DefaultMonthTimestampFromFileNameExtractorRegex, DefaultMonthTimestampFormat, null);
            var dayBackupFileNameParser  = new BackupFilesystemObjectNameParser(DefaultDayTimestampFromFileNameExtractorRegex, DefaultDayTimestampFormat, null);

            var monthPeriodExtractor = TimePeriodFromFilesystemNameExtractor.CreateForCalendarMonths(fullBackupFileNameParser);
            var dayPeriodExtractor   = TimePeriodFromFilesystemNameExtractor.CreateForCalendarDays(dayBackupFileNameParser);

            result.AddType(FullBackupFileNameSuffix, SupportedBackupType.Full, monthPeriodExtractor);
            result.AddType(DiffBackupFileNameSuffix, SupportedBackupType.Diff, dayPeriodExtractor);
            result.AddType(LogBackupFileNameSuffix, SupportedBackupType.Log, dayPeriodExtractor);

            return(result);
        }
Exemple #2
0
        private List <BackupFileInfo> GetBackupFiles(List <FileInfo> files)
        {
            Check.DoRequireArgumentNotNull(files, "files");

            var result = new List <BackupFileInfo>(files.Count);

            var filteredFiles = files.Where(f => BackupFileNamingConvention.GetBackupType(f.Name) != SupportedBackupType.None);

            foreach (var info in filteredFiles)
            {
                var backupFileInfo = BackupFileNamingConvention.GetBackupFileInfo(info);

                result.Add(backupFileInfo);
            }

            result = result.OrderBy(f => f.StartTime).ToList();

            InferEndTimeWhereNotDefinedExplicitly(result);

            return(result);
        }