/// <summary>
        ///     Factory method creating convention for calendar month folders and given file naming convention.
        /// </summary>
        /// <param name="fileNamingConvention">
        ///     File naming convention to use.
        /// </param>
        /// <returns>
        /// </returns>
        public static BackupDirectoryNamingConvention CreateMonthlyConvention(IBackupFileNamingConvention fileNamingConvention)
        {
            Check.DoRequireArgumentNotNull(fileNamingConvention, "fileNamingConvention");

            var monthDirectoryNameParser = new BackupFilesystemObjectNameParser(
                "(.+)", RestoreBackupLib.BackupFileNamingConvention.DefaultMonthTimestampFormat, null);

            var monthPeriodExtractor = TimePeriodFromFilesystemNameExtractor.CreateForCalendarMonths(monthDirectoryNameParser);

            var result = new BackupDirectoryNamingConvention(monthPeriodExtractor, fileNamingConvention);

            return(result);
        }
コード例 #2
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);
        }