Esempio n. 1
0
        public static void Add(BackupModel model)
        {
            using var dbContext = new BackupDbContext(dbOptions);
            var col = new BackupCollection {
                Title = model.Title
            };

            dbContext.BackupCollections.Add(col);
            dbContext.SaveChanges();
            model.Id = col.BackupCollectionId;
        }
Esempio n. 2
0
        public async Task StartAsync(CancellationToken cancellationToken)
        {
            using var scope = _scopeFactory.CreateScope();
            var environment = scope.ServiceProvider.GetService <IWebHostEnvironment>();
            var workingPath = Path.Combine(environment.WebRootPath, "scratch_dir");

            _logger.Log(LogLevel.Information, "Creating backup targets");
            foreach (var child in _section.GetChildren())
            {
                // Construct the backup collection
                var backupCollection = new BackupCollection(child.Key, _scopeFactory, _logger);
                await backupCollection.GetExistingBackups();

                // Construct the backup target itself
                var target = new DbBackupTarget(child.Key, child, workingPath, backupCollection);

                _logger.Log(LogLevel.Information, "Created target {0}", target.Name);
                _targets[child.Key] = target;
                _targets[child.Key].ScheduleNext();
            }
        }