PostgreSQL backup tool with Point-In-Time-Recovery and restore verification
TypeScript backupbackupsdatabasedatabase-backupdevopsdockergolangkubernetesmariadbmongodbmysqlpgpostgrespostgresqls3self-hostedsystem-administrationtoolsweb-ui
FIX (backups): Allow to make manual backups when scheduled are disabled
Rostislav Dugina23d05b73525
diff --git a/backend/internal/features/backups/backups/background_service_test.go b/backend/internal/features/backups/backups/background_service_test.goindex 06a6779b..c1ad79cd 100644--- a/backend/internal/features/backups/backups/background_service_test.go+++ b/backend/internal/features/backups/backups/background_service_test.go@@ -331,3 +331,59 @@ func Test_MakeBackupHavingFailedBackupWithRetries_RetriesCountNotExceeded(t *tesassert.NoError(t, err)assert.Len(t, backups, 3) // Should have 3 backups, not more than max}++func Test_MakeBackgroundBackupWhenBakupsDisabled_BackupSkipped(t *testing.T) {+ user := users_testing.CreateTestUser(users_enums.UserRoleAdmin)+ router := CreateTestRouter()+ workspace := workspaces_testing.CreateTestWorkspace("Test Workspace", user, router)+ storage := storages.CreateTestStorage(workspace.ID)+ notifier := notifiers.CreateTestNotifier(workspace.ID)+ database := databases.CreateTestDatabase(workspace.ID, storage, notifier)++ defer func() {+ backups, _ := backupRepository.FindByDatabaseID(database.ID)+ for _, backup := range backups {+ backupRepository.DeleteByID(backup.ID)+ }++ databases.RemoveTestDatabase(database)+ time.Sleep(50 * time.Millisecond)+ notifiers.RemoveTestNotifier(notifier)+ storages.RemoveTestStorage(storage.ID)+ workspaces_testing.RemoveTestWorkspace(workspace, router)+ }()++ backupConfig, err := backups_config.GetBackupConfigService().GetBackupConfigByDbId(database.ID)+ assert.NoError(t, err)++ timeOfDay := "04:00"+ backupConfig.BackupInterval = &intervals.Interval{+ Interval: intervals.IntervalDaily,+ TimeOfDay: &timeOfDay,+ }+ backupConfig.IsBackupsEnabled = false+ backupConfig.StorePeriod = period.PeriodWeek+ backupConfig.Storage = storage+ backupConfig.StorageID = &storage.ID++ _, err = backups_config.GetBackupConfigService().SaveBackupConfig(backupConfig)+ assert.NoError(t, err)++ // add old backup that would trigger new backup if enabled+ backupRepository.Save(&Backup{+ DatabaseID: database.ID,+ StorageID: storage.ID,++ Status: BackupStatusCompleted,++ CreatedAt: time.Now().UTC().Add(-24 * time.Hour),+ })++ GetBackupBackgroundService().runPendingBackups()++ time.Sleep(100 * time.Millisecond)++ backups, err := backupRepository.FindByDatabaseID(database.ID)+ assert.NoError(t, err)+ assert.Len(t, backups, 1)+}diff --git a/backend/internal/features/backups/backups/service.go b/backend/internal/features/backups/backups/service.goindex 334addfa..86c99472 100644--- a/backend/internal/features/backups/backups/service.go+++ b/backend/internal/features/backups/backups/service.go@@ -214,11 +214,6 @@ func (s *BackupService) MakeBackup(databaseID uuid.UUID, isLastTry bool) {return}- if !backupConfig.IsBackupsEnabled {- s.logger.Info("Backups are not enabled for this database")- return- }-if backupConfig.StorageID == nil {s.logger.Error("Backup config storage ID is not defined")returndiff --git a/backend/internal/features/backups/backups/usecases/mariadb/create_backup_uc.go b/backend/internal/features/backups/backups/usecases/mariadb/create_backup_uc.goindex 352e78f2..d814c063 100644--- a/backend/internal/features/backups/backups/usecases/mariadb/create_backup_uc.go+++ b/backend/internal/features/backups/backups/usecases/mariadb/create_backup_uc.go@@ -64,10 +64,6 @@ func (uc *CreateMariadbBackupUsecase) Execute("storageId", storage.ID,)- if !backupConfig.IsBackupsEnabled {- return nil, fmt.Errorf("backups are not enabled for this database: \"%s\"", db.Name)- }-mdb := db.Mariadbif mdb == nil {return nil, fmt.Errorf("mariadb database configuration is required")diff --git a/backend/internal/features/backups/backups/usecases/mongodb/create_backup_uc.go b/backend/internal/features/backups/backups/usecases/mongodb/create_backup_uc.goindex 9169e5a9..45919c70 100644--- a/backend/internal/features/backups/backups/usecases/mongodb/create_backup_uc.go+++ b/backend/internal/features/backups/backups/usecases/mongodb/create_backup_uc.go@@ -58,10 +58,6 @@ func (uc *CreateMongodbBackupUsecase) Execute("storageId", storage.ID,)- if !backupConfig.IsBackupsEnabled {- return nil, fmt.Errorf("backups are not enabled for this database: \"%s\"", db.Name)- }-mdb := db.Mongodbif mdb == nil {return nil, fmt.Errorf("mongodb database configuration is required")diff --git a/backend/internal/features/backups/backups/usecases/mysql/create_backup_uc.go b/backend/internal/features/backups/backups/usecases/mysql/create_backup_uc.goindex 91a59fe2..7eee4d79 100644--- a/backend/internal/features/backups/backups/usecases/mysql/create_backup_uc.go+++ b/backend/internal/features/backups/backups/usecases/mysql/create_backup_uc.go@@ -64,10 +64,6 @@ func (uc *CreateMysqlBackupUsecase) Execute("storageId", storage.ID,)- if !backupConfig.IsBackupsEnabled {- return nil, fmt.Errorf("backups are not enabled for this database: \"%s\"", db.Name)- }-my := db.Mysqlif my == nil {return nil, fmt.Errorf("mysql database configuration is required")diff --git a/backend/internal/features/backups/backups/usecases/postgresql/create_backup_uc.go b/backend/internal/features/backups/backups/usecases/postgresql/create_backup_uc.goindex 3a6145d6..d24eca54 100644--- a/backend/internal/features/backups/backups/usecases/postgresql/create_backup_uc.go+++ b/backend/internal/features/backups/backups/usecases/postgresql/create_backup_uc.go@@ -69,10 +69,6 @@ func (uc *CreatePostgresqlBackupUsecase) Execute(storage.ID,)- if !backupConfig.IsBackupsEnabled {- return nil, fmt.Errorf("backups are not enabled for this database: \"%s\"", db.Name)- }-pg := db.Postgresqlif pg == nil {