Ejemplo n.º 1
0
        public void CreateSchedule(BackupStorageType storageType, StorageParams storageParams, int backupsStored, CronParams cronParams, bool backupMail)
        {
            DemandPermissionsBackup();
            DemandSize();

            if (!SetupInfo.IsVisibleSettings("AutoBackup"))
            {
                throw new InvalidOperationException(Resource.ErrorNotAllowedOption);
            }

            ValidateCronSettings(cronParams);

            var scheduleRequest = new CreateScheduleRequest
            {
                TenantId              = CoreContext.TenantManager.GetCurrentTenant().TenantId,
                BackupMail            = backupMail,
                Cron                  = cronParams.ToString(),
                NumberOfBackupsStored = backupsStored,
                StorageType           = storageType
            };

            switch (storageType)
            {
            case BackupStorageType.ThridpartyDocuments:
            case BackupStorageType.Documents:
                scheduleRequest.StorageBasePath = storageParams.FolderId;
                break;

            case BackupStorageType.CustomCloud:
                ValidateS3Settings(storageParams.AccessKeyId, storageParams.SecretAccessKey, storageParams.Bucket, storageParams.Region);
                CoreContext.Configuration.SaveSection(
                    new AmazonS3Settings
                {
                    AccessKeyId     = storageParams.AccessKeyId,
                    SecretAccessKey = storageParams.SecretAccessKey,
                    Bucket          = storageParams.Bucket,
                    Region          = storageParams.Region
                });
                break;
            }

            using (var service = new BackupServiceClient())
            {
                service.CreateSchedule(scheduleRequest);
            }
        }
Ejemplo n.º 2
0
        public void CreateSchedule(BackupStorageType storageType, Dictionary <string, string> storageParams, int backupsStored, CronParams cronParams, bool backupMail)
        {
            DemandPermissionsBackup();
            DemandSize();

            if (!SetupInfo.IsVisibleSettings("AutoBackup"))
            {
                throw new InvalidOperationException(Resource.ErrorNotAllowedOption);
            }

            ValidateCronSettings(cronParams);

            var scheduleRequest = new CreateScheduleRequest
            {
                TenantId              = CoreContext.TenantManager.GetCurrentTenant().TenantId,
                BackupMail            = backupMail,
                Cron                  = cronParams.ToString(),
                NumberOfBackupsStored = backupsStored,
                StorageType           = storageType,
                StorageParams         = storageParams
            };

            switch (storageType)
            {
            case BackupStorageType.ThridpartyDocuments:
            case BackupStorageType.Documents:
                scheduleRequest.StorageBasePath = storageParams["folderId"];
                break;

            case BackupStorageType.Local:
                if (!CoreContext.Configuration.Standalone)
                {
                    throw new Exception("Access denied");
                }
                scheduleRequest.StorageBasePath = storageParams["filePath"];
                break;
            }

            using (var service = new BackupServiceClient())
            {
                service.CreateSchedule(scheduleRequest);
            }
        }
Ejemplo n.º 3
0
 private static void ValidateCronSettings(CronParams cronParams)
 {
     new CronExpression(cronParams.ToString());
 }
Ejemplo n.º 4
0
 private static void ValidateCronSettings(CronParams cronParams)
 {
     new CronExpression(cronParams.ToString());
 }
Ejemplo n.º 5
0
        public void CreateSchedule(BackupStorageType storageType, StorageParams storageParams, int backupsStored, CronParams cronParams, bool backupMail)
        {
            DemandPermissions();

            ValidateCronSettings(cronParams);

            var scheduleRequest = new CreateScheduleRequest
                {
                    TenantId = CoreContext.TenantManager.GetCurrentTenant().TenantId,
                    BackupMail = backupMail,
                    Cron = cronParams.ToString(),
                    NumberOfBackupsStored = backupsStored,
                    StorageType = storageType
                };

            switch (storageType)
            {
                case BackupStorageType.ThridpartyDocuments:
                case BackupStorageType.Documents:
                    scheduleRequest.StorageBasePath = storageParams.FolderId;
                    break;
                case BackupStorageType.CustomCloud:
                    ValidateS3Settings(storageParams.AccessKeyId, storageParams.SecretAccessKey, storageParams.Bucket, storageParams.Region);
                    CoreContext.Configuration.SaveSection(
                        new AmazonS3Settings
                            {
                                AccessKeyId = storageParams.AccessKeyId,
                                SecretAccessKey = storageParams.SecretAccessKey,
                                Bucket = storageParams.Bucket,
                                Region = storageParams.Region
                            });
                    break;
            }

            using (var service = new BackupServiceClient())
            {
                service.CreateSchedule(scheduleRequest);
            }
        }