コード例 #1
0
        public BackupTask(DocumentDatabase database, BackupParameters backupParameters, BackupConfiguration configuration, Logger logger, PeriodicBackupRunner.TestingStuff forTestingPurposes = null)
        {
            _database             = database;
            _taskName             = backupParameters.Name;
            _operationId          = backupParameters.OperationId;
            _previousBackupStatus = backupParameters.BackupStatus;
            _startTimeUtc         = backupParameters.StartTimeUtc;
            _isOneTimeBackup      = backupParameters.IsOneTimeBackup;
            _isFullBackup         = backupParameters.IsFullBackup;
            _backupToLocalFolder  = backupParameters.BackupToLocalFolder;
            _tempBackupPath       = backupParameters.TempBackupPath;
            _configuration        = configuration;
            _logger             = logger;
            _isServerWide       = backupParameters.Name?.StartsWith(ServerWideBackupConfiguration.NamePrefix, StringComparison.OrdinalIgnoreCase) ?? false;
            _isBackupEncrypted  = IsBackupEncrypted(_database, _configuration);
            _forTestingPurposes = forTestingPurposes;
            _backupResult       = GenerateBackupResult();
            TaskCancelToken     = new OperationCancelToken(_database.DatabaseShutdown, CancellationToken.None);

            _retentionPolicyParameters = new RetentionPolicyBaseParameters
            {
                RetentionPolicy   = backupParameters.RetentionPolicy,
                DatabaseName      = _database.Name,
                IsFullBackup      = _isFullBackup,
                OnProgress        = AddInfo,
                CancellationToken = TaskCancelToken.Token
            };
        }
コード例 #2
0
        public BackupTask(
            ServerStore serverStore,
            DocumentDatabase database,
            PeriodicBackup periodicBackup,
            bool isFullBackup,
            bool backupToLocalFolder,
            long operationId,
            PathSetting tempBackupPath,
            Logger logger,
            CancellationToken databaseShutdownCancellationToken)
        {
            _serverStore          = serverStore;
            _database             = database;
            _startTime            = periodicBackup.StartTime;
            _periodicBackup       = periodicBackup;
            _configuration        = periodicBackup.Configuration;
            _previousBackupStatus = periodicBackup.BackupStatus;
            _isFullBackup         = isFullBackup;
            _backupToLocalFolder  = backupToLocalFolder;
            _operationId          = operationId;
            _tempBackupPath       = tempBackupPath;
            _logger = logger;
            _databaseShutdownCancellationToken = databaseShutdownCancellationToken;

            TaskCancelToken = new OperationCancelToken(_databaseShutdownCancellationToken);
            _backupResult   = GenerateBackupResult();
        }
コード例 #3
0
        public BackupUploader(BackupUploaderSettings settings, RetentionPolicyBaseParameters retentionPolicyParameters, Logger logger, BackupResult backupResult, Action <IOperationProgress> onProgress, OperationCancelToken taskCancelToken)
        {
            _settings   = settings ?? throw new ArgumentNullException(nameof(settings));
            _threads    = new List <PoolOfThreads.LongRunningWork>();
            _exceptions = new ConcurrentSet <Exception>();

            _retentionPolicyParameters = retentionPolicyParameters;
            _isFullBackup = retentionPolicyParameters.IsFullBackup;

            TaskCancelToken = taskCancelToken;
            _logger         = logger;
            _backupResult   = backupResult;
            _onProgress     = onProgress;
        }
コード例 #4
0
        public BackupTask(
            ServerStore serverStore,
            DocumentDatabase database,
            PeriodicBackup periodicBackup,
            bool isFullBackup,
            bool backupToLocalFolder,
            long operationId,
            PathSetting tempBackupPath,
            Logger logger,
            CancellationToken databaseShutdownCancellationToken,
            PeriodicBackupRunner.TestingStuff forTestingPurposes = null)
        {
            _serverStore          = serverStore;
            _database             = database;
            _periodicBackup       = periodicBackup;
            _configuration        = periodicBackup.Configuration;
            _isServerWide         = _configuration.Name?.StartsWith(ServerWideBackupConfiguration.NamePrefix, StringComparison.OrdinalIgnoreCase) ?? false;
            _isBackupEncrypted    = IsBackupEncrypted(_database, _configuration);
            _previousBackupStatus = periodicBackup.BackupStatus;
            _isFullBackup         = isFullBackup;
            _backupToLocalFolder  = backupToLocalFolder;
            _operationId          = operationId;
            _tempBackupPath       = tempBackupPath;
            _logger = logger;
            _databaseShutdownCancellationToken = databaseShutdownCancellationToken;
            _forTestingPurposes = forTestingPurposes;

            TaskCancelToken = new OperationCancelToken(_databaseShutdownCancellationToken);
            _backupResult   = GenerateBackupResult();

            _retentionPolicyParameters = new RetentionPolicyBaseParameters
            {
                RetentionPolicy   = _configuration.RetentionPolicy,
                DatabaseName      = _database.Name,
                IsFullBackup      = _isFullBackup,
                OnProgress        = AddInfo,
                CancellationToken = TaskCancelToken.Token
            };
        }
コード例 #5
0
        public static void SaveBackupStatus(PeriodicBackupStatus status, DocumentDatabase documentDatabase, Logger logger, BackupResult backupResult)
        {
            try
            {
                var command = new UpdatePeriodicBackupStatusCommand(documentDatabase.Name, RaftIdGenerator.NewId())
                {
                    PeriodicBackupStatus = status
                };

                var result = AsyncHelpers.RunSync(() => documentDatabase.ServerStore.SendToLeaderAsync(command));
                AsyncHelpers.RunSync(() => documentDatabase.ServerStore.WaitForCommitIndexChange(RachisConsensus.CommitIndexModification.GreaterOrEqual, result.Index));

                if (logger.IsInfoEnabled)
                {
                    logger.Info($"Periodic backup status with task id {status.TaskId} was updated");
                }
            }
            catch (Exception e)
            {
                const string message = "Error saving the periodic backup status";

                if (logger.IsOperationsEnabled)
                {
                    logger.Operations(message, e);
                }

                backupResult?.AddError($"{message}{Environment.NewLine}{e}");
            }
        }
コード例 #6
0
 public BackupProgress(BackupResult result) : base(result)
 {
 }