Пример #1
0
        public List <BackupHistoryRecord> GetBackupHistory(int tenantId)
        {
            var backupHistory = new List <BackupHistoryRecord>();

            foreach (var record in BackupRepository.GetBackupRecordsByTenantId(tenantId))
            {
                var storage = BackupStorageFactory.GetBackupStorage(record);
                if (storage == null)
                {
                    continue;
                }
                if (storage.IsExists(record.StoragePath))
                {
                    backupHistory.Add(new BackupHistoryRecord
                    {
                        Id          = record.Id,
                        FileName    = record.Name,
                        StorageType = record.StorageType,
                        CreatedOn   = record.CreatedOn,
                        ExpiresOn   = record.ExpiresOn
                    });
                }
                else
                {
                    BackupRepository.DeleteBackupRecord(record.Id);
                }
            }
            return(backupHistory);
        }
Пример #2
0
 public void DeleteAllBackups(int tenantId)
 {
     foreach (var backupRecord in BackupRepository.GetBackupRecordsByTenantId(tenantId))
     {
         try
         {
             BackupRepository.DeleteBackupRecord(backupRecord.Id);
             var storage = BackupStorageFactory.GetBackupStorage(backupRecord);
             if (storage == null)
             {
                 continue;
             }
             storage.Delete(backupRecord.StoragePath);
         }
         catch (Exception error)
         {
             Log.Warn("error while removing backup record: {0}", error);
         }
     }
 }