PostgreSQL backup tool with Point-In-Time-Recovery and restore verification
TypeScript backupbackupsdatabasedatabase-backupdevopsdockergolangkubernetesmariadbmongodbmysqlpgpostgrespostgresqls3self-hostedsystem-administrationtoolsweb-ui
FEATURE (backups): Remove the next scheduled backup display and its endpoints, since it cluttered every database card and the read-only cron preview could disagree with the scheduler
Rostislav Dugina32a47344466
diff --git a/backend/internal/features/backups/backups/backuping/logical/scheduler.go b/backend/internal/features/backups/backups/backuping/logical/scheduler.goindex 96f0c423..d6439061 100644--- a/backend/internal/features/backups/backups/backuping/logical/scheduler.go+++ b/backend/internal/features/backups/backups/backuping/logical/scheduler.go@@ -12,7 +12,6 @@ import (backups_core_logical "databasus-backend/internal/features/backups/backups/core/logical"backups_config_logical "databasus-backend/internal/features/backups/config/logical""databasus-backend/internal/features/databases"- "databasus-backend/internal/features/intervals"task_cancellation "databasus-backend/internal/features/tasks/cancellation")@@ -252,29 +251,6 @@ func (s *BackupsScheduler) GetRemainedBackupTryCount(return remainedTryCount}-// GetNextScheduledBackup reads the same inputs runPendingBackups and StartBackup act on,-// so the reported time is when this scheduler will actually start the backup.-func (s *BackupsScheduler) GetNextScheduledBackup(- databaseID uuid.UUID,- now time.Time,-) (*intervals.NextTrigger, error) {- backupConfig, err := s.backupConfigService.FindBackupConfigByDbId(databaseID)- if err != nil {- return nil, err- }-- if backupConfig == nil || !backupConfig.IsBackupsEnabled || backupConfig.StorageID == nil {- return nil, nil- }-- lastBackup, err := s.backupRepository.FindLastByDatabaseID(databaseID)- if err != nil {- return nil, err- }-- return backupConfig.BackupInterval.GetNextTrigger(now, createdAtOrNil(lastBackup)), nil-}-func (s *BackupsScheduler) runPendingBackups(ctx context.Context, logger *slog.Logger) error {enabledBackupConfigs, err := s.backupConfigService.GetBackupConfigsWithEnabledBackups()if err != nil {@@ -294,7 +270,10 @@ func (s *BackupsScheduler) runPendingBackups(ctx context.Context, logger *slog.Lcontinue}- lastBackupTime := createdAtOrNil(lastBackup)+ var lastBackupTime *time.Time+ if lastBackup != nil {+ lastBackupTime = &lastBackup.CreatedAt+ }remainedBackupTryCount := s.GetRemainedBackupTryCount(ctx, logger, lastBackup)@@ -380,11 +359,3 @@ func (s *BackupsScheduler) onBackupCompleted(backupID uuid.UUID) {go listener.OnBackupCompleted(backupID)}}--func createdAtOrNil(backup *backups_core_logical.LogicalBackup) *time.Time {- if backup == nil {- return nil- }-- return &backup.CreatedAt-}diff --git a/backend/internal/features/backups/backups/backuping/physical/scheduler.go b/backend/internal/features/backups/backups/backuping/physical/scheduler.goindex 9f6dcede..b3eec17f 100644--- a/backend/internal/features/backups/backups/backuping/physical/scheduler.go+++ b/backend/internal/features/backups/backups/backuping/physical/scheduler.go@@ -18,7 +18,6 @@ import (physical_repositories "databasus-backend/internal/features/backups/backups/core/physical/repositories"backups_config_physical "databasus-backend/internal/features/backups/config/physical"postgresql_physical "databasus-backend/internal/features/databases/databases/postgresql/physical"- "databasus-backend/internal/features/intervals"storage_files "databasus-backend/internal/features/storages/files"tasks_cancellation "databasus-backend/internal/features/tasks/cancellation""databasus-backend/internal/storage"@@ -113,61 +112,6 @@ func (s *PhysicalBackupsScheduler) Run(ctx context.Context) {}}-// GetNextScheduledBackups reads the same inputs evaluateConfig and decideBackupKind act on,-// so the reported times are when this scheduler will actually start each cadence.-func (s *PhysicalBackupsScheduler) GetNextScheduledBackups(- databaseID uuid.UUID,- now time.Time,-) (nextFullBackup, nextIncrementalBackup *intervals.NextTrigger, err error) {- backupConfig, err := s.backupConfigService.FindBackupConfigByDbId(databaseID)- if err != nil {- return nil, nil, err- }-- if backupConfig == nil || !backupConfig.IsBackupsEnabled || backupConfig.StorageID == nil {- return nil, nil, nil- }-- hasUnresolvedMismatch, err := hasUnresolvedSystemIdentifierMismatch(storage.GetDb(), databaseID)- if err != nil {- return nil, nil, err- }-- if hasUnresolvedMismatch {- return nil, nil, nil- }-- lastFull, err := s.fullRepo.FindLastFullAnyStatusByDatabase(databaseID)- if err != nil {- return nil, nil, err- }-- nextFullBackup = backupConfig.FullBackupInterval.GetNextTrigger(now, createdAtOrNil(lastFull))-- if !isIncrementalEnabled(backupConfig) {- return nextFullBackup, nil, nil- }-- lastIncr, err := s.incrRepo.FindLastByDatabase(databaseID)- if err != nil {- return nil, nil, err- }-- isHeldBack, err := s.isIncrementalChainHeldBack(databaseID, lastIncr)- if err != nil {- return nil, nil, err- }-- if isHeldBack {- return nextFullBackup, nil, nil- }-- nextIncrementalBackup = backupConfig.IncrementalBackupInterval.GetNextTrigger(- now, newestCreatedAt(lastFull, lastIncr))-- return nextFullBackup, nextIncrementalBackup, nil-}-func (s *PhysicalBackupsScheduler) runPendingBackups(ctx context.Context, logger *slog.Logger) error {enabledConfigs, err := s.backupConfigService.GetBackupConfigsWithEnabledBackups()if err != nil {@@ -322,27 +266,6 @@ func (s *PhysicalBackupsScheduler) decideBackupKind(}, true}-func (s *PhysicalBackupsScheduler) isIncrementalChainHeldBack(- databaseID uuid.UUID,- lastIncr *physical_models.PhysicalIncrementalBackup,-) (bool, error) {- extendableChain, err := s.chainViewService.FindLastExtendableChainByDatabase(databaseID)- if err != nil {- return false, err- }-- if extendableChain != nil {- return false, nil- }-- holdBackReason, err := s.getChainlessIncrementalHoldBackReason(databaseID, lastIncr)- if err != nil {- return false, err- }-- return holdBackReason != "", nil-}-// decideForcedIncremental honors an out-of-cadence incremental request. It can// only be satisfied when incrementals are enabled and an extendable chain// exists; otherwise the stale request is cleared (so it can't loop forever) and@@ -953,15 +876,24 @@ func (s *PhysicalBackupsScheduler) decideReAnchoringFull(backupConfig *backups_config_physical.PhysicalBackupConfig,lastIncr *physical_models.PhysicalIncrementalBackup,) (backupDecision, bool) {- holdBackReason, err := s.getChainlessIncrementalHoldBackReason(backupConfig.DatabaseID, lastIncr)+ if isChainBrokenBySummarizerOff(lastIncr) {+ logger.Debug("nothing due: chain broken by summarizer off, which a fresh FULL cannot fix")++ return backupDecision{}, false+ }++ recentFullBackups, err := s.fullRepo.FindNewestAnyStatusByDatabase(+ backupConfig.DatabaseID, recentFullAttemptsWindow)if err != nil {logger.Error("failed to find recent full backups", "error", err)return backupDecision{}, false}- if holdBackReason != "" {- logger.Debug(holdBackReason)+ if hasNoRecentCompletedFull(recentFullBackups) {+ logger.Debug(fmt.Sprintf(+ "nothing due: no extendable chain and no completed full among the newest %d",+ recentFullAttemptsWindow))return backupDecision{}, false}@@ -972,31 +904,6 @@ func (s *PhysicalBackupsScheduler) decideReAnchoringFull(}, true}-// getChainlessIncrementalHoldBackReason answers, for a database with no extendable-// chain, why a due incremental cadence must not re-anchor with a FULL. An empty-// reason means re-anchoring may go ahead.-func (s *PhysicalBackupsScheduler) getChainlessIncrementalHoldBackReason(- databaseID uuid.UUID,- lastIncr *physical_models.PhysicalIncrementalBackup,-) (string, error) {- if isChainBrokenBySummarizerOff(lastIncr) {- return "nothing due: chain broken by summarizer off, which a fresh FULL cannot fix", nil- }-- recentFullBackups, err := s.fullRepo.FindNewestAnyStatusByDatabase(databaseID, recentFullAttemptsWindow)- if err != nil {- return "", err- }-- if hasNoRecentCompletedFull(recentFullBackups) {- return fmt.Sprintf(- "nothing due: no extendable chain and no completed full among the newest %d",- recentFullAttemptsWindow), nil- }-- return "", nil-}-// The newest incremental row is the right witness: any completed INCR after it// would have kept the chain extendable, so this branch would not run at all.// Once the operator re-enables summarize_wal, incrementals resume with the nextdiff --git a/backend/internal/features/backups/backups/controllers/logical/controller.go b/backend/internal/features/backups/backups/controllers/logical/controller.goindex 94dd5d16..95edffdc 100644--- a/backend/internal/features/backups/backups/controllers/logical/controller.go+++ b/backend/internal/features/backups/backups/controllers/logical/controller.go@@ -26,7 +26,6 @@ type BackupController struct {func (c *BackupController) RegisterRoutes(router *gin.RouterGroup) {router.GET("/backups", c.GetBackups)- router.GET("/backups/database/:id/next-backup", c.GetNextScheduledBackup)router.POST("/backups", c.MakeBackup)router.POST("/backups/:id/download-token", c.GenerateDownloadToken)router.DELETE("/backups/:id", c.DeleteBackup)@@ -92,39 +91,6 @@ func (c *BackupController) GetBackups(ctx *gin.Context) {ctx.JSON(http.StatusOK, response)}-// GetNextScheduledBackup-// @Summary Get the next scheduled backup of a logical database-// @Description Get when the scheduler will start the next automatic backup. nextBackup is null when no automatic backup will run.-// @Tags backups-// @Produce json-// @Security BearerAuth-// @Param id path string true "Database ID"-// @Success 200 {object} backups_dto_logical.GetNextScheduledBackupResponse-// @Failure 400 {object} map[string]string-// @Failure 401 {object} map[string]string-// @Router /backups/database/{id}/next-backup [get]-func (c *BackupController) GetNextScheduledBackup(ctx *gin.Context) {- user, ok := users_middleware.GetUserFromContext(ctx)- if !ok {- ctx.JSON(http.StatusUnauthorized, gin.H{"error": "User not authenticated"})- return- }-- databaseID, err := uuid.Parse(ctx.Param("id"))- if err != nil {- ctx.JSON(http.StatusBadRequest, gin.H{"error": "invalid database ID"})- return- }-- response, err := c.backupService.GetNextScheduledBackup(ctx.Request.Context(), user, databaseID)- if err != nil {- ctx.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})- return- }-- ctx.JSON(http.StatusOK, response)-}-// MakeBackup// @Summary Create a backup// @Description Create a new backup for the specified databasediff --git a/backend/internal/features/backups/backups/controllers/logical/controller_test.go b/backend/internal/features/backups/backups/controllers/logical/controller_test.goindex 0fb09c0d..a84cc856 100644--- a/backend/internal/features/backups/backups/controllers/logical/controller_test.go+++ b/backend/internal/features/backups/backups/controllers/logical/controller_test.go@@ -30,8 +30,6 @@ import (backups_config_logical "databasus-backend/internal/features/backups/config/logical""databasus-backend/internal/features/databases"postgresql_logical "databasus-backend/internal/features/databases/databases/postgresql/logical"- "databasus-backend/internal/features/intervals"- "databasus-backend/internal/features/notifiers""databasus-backend/internal/features/storages"storage_files "databasus-backend/internal/features/storages/files"local_storage "databasus-backend/internal/features/storages/models/local"@@ -1703,270 +1701,3 @@ func Test_DeleteBackup_RemovesBackupAndMetadataFilesFromDisk(t *testing.T) {_, err = os.Stat(metadataFilePath)assert.True(t, os.IsNotExist(err), "metadata file should be removed from disk after deletion")}--func Test_GetNextScheduledBackup_WhenDailySlotIsAhead_ReturnsSlot(t *testing.T) {- router := createTestRouter()- owner := users_testing.CreateTestUser(t.Context(), users_enums.UserRoleMember)- workspace := workspaces_testing.CreateTestWorkspace(t.Context(), "Test Workspace", owner, router)- database := createTestDatabase("Test Database", workspace.ID, owner.Token, router)- storage := createTestStorage(workspace.ID)- defer cleanupNextScheduledBackupTest(t, database, storage, workspace, router)-- now := time.Now().UTC()- dailySlot := now.Add(3 * time.Hour).Truncate(time.Minute)- saveNextScheduledBackupTestConfig(t, database.ID, &storage.ID, true, intervals.Interval{- Type: intervals.IntervalDaily,- TimeOfDay: new(dailySlot.Format("15:04")),- })- CreateTestBackupWithOptions(database.ID, storage.ID, TestBackupOptions{- Status: backups_core_logical.BackupStatusCompleted,- CreatedAt: now,- })-- response := getNextScheduledBackup(t, router, database.ID, owner.Token)-- require.NotNil(t, response.NextBackup)- assert.False(t, response.NextBackup.IsDue)- assert.True(t, dailySlot.Equal(response.NextBackup.ScheduledAt),- "next backup %s, reported %s", dailySlot, response.NextBackup.ScheduledAt)-}--func Test_GetNextScheduledBackup_WhenDailySlotWasMissed_ReportsDue(t *testing.T) {- router := createTestRouter()- owner := users_testing.CreateTestUser(t.Context(), users_enums.UserRoleMember)- workspace := workspaces_testing.CreateTestWorkspace(t.Context(), "Test Workspace", owner, router)- database := createTestDatabase("Test Database", workspace.ID, owner.Token, router)- storage := createTestStorage(workspace.ID)- defer cleanupNextScheduledBackupTest(t, database, storage, workspace, router)-- saveNextScheduledBackupTestConfig(t, database.ID, &storage.ID, true, intervals.Interval{- Type: intervals.IntervalDaily,- TimeOfDay: new("03:00"),- })- CreateTestBackupWithOptions(database.ID, storage.ID, TestBackupOptions{- Status: backups_core_logical.BackupStatusFailed,- CreatedAt: time.Now().UTC().AddDate(0, 0, -3),- })-- response := getNextScheduledBackup(t, router, database.ID, owner.Token)-- require.NotNil(t, response.NextBackup)- assert.True(t, response.NextBackup.IsDue)-}--func Test_GetNextScheduledBackup_WhenHourlyBackupFailed_CountsFailedBackup(t *testing.T) {- router := createTestRouter()- owner := users_testing.CreateTestUser(t.Context(), users_enums.UserRoleMember)- workspace := workspaces_testing.CreateTestWorkspace(t.Context(), "Test Workspace", owner, router)- database := createTestDatabase("Test Database", workspace.ID, owner.Token, router)- storage := createTestStorage(workspace.ID)- defer cleanupNextScheduledBackupTest(t, database, storage, workspace, router)-- failedBackupTime := time.Now().UTC().Add(-20 * time.Minute).Truncate(time.Second)- saveNextScheduledBackupTestConfig(t, database.ID, &storage.ID, true, intervals.Interval{- Type: intervals.IntervalHourly,- })- CreateTestBackupWithOptions(database.ID, storage.ID, TestBackupOptions{- Status: backups_core_logical.BackupStatusCompleted,- CreatedAt: failedBackupTime.Add(-5 * time.Hour),- })- CreateTestBackupWithOptions(database.ID, storage.ID, TestBackupOptions{- Status: backups_core_logical.BackupStatusFailed,- CreatedAt: failedBackupTime,- })-- response := getNextScheduledBackup(t, router, database.ID, owner.Token)-- require.NotNil(t, response.NextBackup)- assert.False(t, response.NextBackup.IsDue)- assert.True(t, failedBackupTime.Add(time.Hour).Equal(response.NextBackup.ScheduledAt),- "next backup %s, reported %s", failedBackupTime.Add(time.Hour), response.NextBackup.ScheduledAt)-}--func Test_GetNextScheduledBackup_WhenNoBackupExists_ReportsDue(t *testing.T) {- router := createTestRouter()- owner := users_testing.CreateTestUser(t.Context(), users_enums.UserRoleMember)- workspace := workspaces_testing.CreateTestWorkspace(t.Context(), "Test Workspace", owner, router)- database := createTestDatabase("Test Database", workspace.ID, owner.Token, router)- storage := createTestStorage(workspace.ID)- defer cleanupNextScheduledBackupTest(t, database, storage, workspace, router)-- saveNextScheduledBackupTestConfig(t, database.ID, &storage.ID, true, intervals.Interval{- Type: intervals.IntervalDaily,- TimeOfDay: new("03:00"),- })-- response := getNextScheduledBackup(t, router, database.ID, owner.Token)-- require.NotNil(t, response.NextBackup)- assert.True(t, response.NextBackup.IsDue)-}--func Test_GetNextScheduledBackup_WhenAutomaticBackupsWillNotRun_ReturnsNoNextBackup(t *testing.T) {- testCases := []struct {- name string- isBackupsEnabled bool- hasStorage bool- }{- {name: "backups disabled", isBackupsEnabled: false, hasStorage: true},- {name: "storage missing", isBackupsEnabled: true, hasStorage: false},- }-- for _, testCase := range testCases {- t.Run(testCase.name, func(t *testing.T) {- router := createTestRouter()- owner := users_testing.CreateTestUser(t.Context(), users_enums.UserRoleMember)- workspace := workspaces_testing.CreateTestWorkspace(t.Context(), "Test Workspace", owner, router)- database := createTestDatabase("Test Database", workspace.ID, owner.Token, router)- storage := createTestStorage(workspace.ID)- defer cleanupNextScheduledBackupTest(t, database, storage, workspace, router)-- var storageID *uuid.UUID- if testCase.hasStorage {- storageID = &storage.ID- }-- saveNextScheduledBackupTestConfig(t, database.ID, storageID, testCase.isBackupsEnabled,- intervals.Interval{Type: intervals.IntervalDaily, TimeOfDay: new("03:00")})-- response := getNextScheduledBackup(t, router, database.ID, owner.Token)-- assert.Nil(t, response.NextBackup)- })- }-}--func Test_GetNextScheduledBackup_WhenBackupConfigWasNeverSaved_ReturnsNoNextBackupAndCreatesNoConfig(t *testing.T) {- router := createTestRouter()- owner := users_testing.CreateTestUser(t.Context(), users_enums.UserRoleMember)- workspace := workspaces_testing.CreateTestWorkspace(t.Context(), "Test Workspace", owner, router)- database := createTestDatabase("Test Database", workspace.ID, owner.Token, router)- storage := createTestStorage(workspace.ID)- defer cleanupNextScheduledBackupTest(t, database, storage, workspace, router)-- response := getNextScheduledBackup(t, router, database.ID, owner.Token)-- assert.Nil(t, response.NextBackup)-- backupConfig, err := backups_config_logical.GetBackupConfigService().FindBackupConfigByDbId(database.ID)- require.NoError(t, err)- assert.Nil(t, backupConfig)-}--func Test_GetNextScheduledBackup_WhenDatabaseIsPhysical_ReturnsBadRequest(t *testing.T) {- router := createTestRouter()- owner := users_testing.CreateTestUser(t.Context(), users_enums.UserRoleMember)- workspace := workspaces_testing.CreateTestWorkspace(t.Context(), "Test Workspace", owner, router)- notifier := notifiers.CreateTestNotifier(workspace.ID)- database := databases.CreateTestPhysicalPostgresDatabase(workspace.ID, notifier, "17")- defer func() {- databases.RemoveTestDatabase(t.Context(), database)- notifiers.RemoveTestNotifier(notifier)- workspaces_testing.RemoveTestWorkspace(t.Context(), workspace, router)- }()-- response := test_utils.MakeGetRequest(- t,- router,- "/api/v1/backups/database/"+database.ID.String()+"/next-backup",- "Bearer "+owner.Token,- http.StatusBadRequest,- )-- assert.Contains(t, string(response.Body), "physical backups")-}--func Test_GetNextScheduledBackup_WhenUserIsOutsideWorkspace_ReturnsBadRequest(t *testing.T) {- router := createTestRouter()- owner := users_testing.CreateTestUser(t.Context(), users_enums.UserRoleMember)- workspace := workspaces_testing.CreateTestWorkspace(t.Context(), "Test Workspace", owner, router)- database := createTestDatabase("Test Database", workspace.ID, owner.Token, router)- storage := createTestStorage(workspace.ID)- defer cleanupNextScheduledBackupTest(t, database, storage, workspace, router)-- saveNextScheduledBackupTestConfig(t, database.ID, &storage.ID, true, intervals.Interval{- Type: intervals.IntervalDaily,- TimeOfDay: new("03:00"),- })- nonMember := users_testing.CreateTestUser(t.Context(), users_enums.UserRoleMember)-- response := test_utils.MakeGetRequest(- t,- router,- "/api/v1/backups/database/"+database.ID.String()+"/next-backup",- "Bearer "+nonMember.Token,- http.StatusBadRequest,- )-- assert.Contains(t, string(response.Body), "insufficient permissions")- assert.NotContains(t, string(response.Body), "nextBackup")-}--func Test_GetNextScheduledBackup_WhenRequestIsUnauthenticated_ReturnsUnauthorized(t *testing.T) {- router := createTestRouter()-- test_utils.MakeGetRequest(- t,- router,- "/api/v1/backups/database/"+uuid.New().String()+"/next-backup",- "",- http.StatusUnauthorized,- )-}--func getNextScheduledBackup(- t *testing.T,- router *gin.Engine,- databaseID uuid.UUID,- token string,-) *backups_dto_logical.GetNextScheduledBackupResponse {- t.Helper()-- var response backups_dto_logical.GetNextScheduledBackupResponse- test_utils.MakeGetRequestAndUnmarshal(- t,- router,- "/api/v1/backups/database/"+databaseID.String()+"/next-backup",- "Bearer "+token,- http.StatusOK,- &response,- )-- return &response-}--func saveNextScheduledBackupTestConfig(- t *testing.T,- databaseID uuid.UUID,- storageID *uuid.UUID,- isBackupsEnabled bool,- interval intervals.Interval,-) {- t.Helper()-- configService := backups_config_logical.GetBackupConfigService()-- backupConfig, err := configService.GetBackupConfigByDbId(databaseID)- require.NoError(t, err)-- backupConfig.IsBackupsEnabled = isBackupsEnabled- backupConfig.StorageID = storageID- backupConfig.Storage = nil- backupConfig.BackupInterval = interval-- _, err = configService.SaveBackupConfig(t.Context(), backupConfig)- require.NoError(t, err)-}--func cleanupNextScheduledBackupTest(- t *testing.T,- database *databases.Database,- storage *storages.Storage,- workspace *workspaces_models.Workspace,- router *gin.Engine,-) {- databases.RemoveTestDatabase(t.Context(), database)- time.Sleep(50 * time.Millisecond)- storages.RemoveTestStorage(t.Context(), storage.ID)- workspaces_testing.RemoveTestWorkspace(t.Context(), workspace, router)-}diff --git a/backend/internal/features/backups/backups/controllers/physical/controller.go b/backend/internal/features/backups/backups/controllers/physical/controller.goindex 1d360f48..613837cf 100644--- a/backend/internal/features/backups/backups/controllers/physical/controller.go+++ b/backend/internal/features/backups/backups/controllers/physical/controller.go@@ -27,7 +27,6 @@ type PhysicalBackupController struct {func (c *PhysicalBackupController) RegisterRoutes(router *gin.RouterGroup) {router.GET("/backups/physical/database/:id/backups", c.GetBackups)- router.GET("/backups/physical/database/:id/next-backups", c.GetNextScheduledBackups)router.POST("/backups/physical/database/:id/trigger", c.TriggerBackup)router.POST("/backups/physical/database/:id/restore-token", c.GenerateRestoreToken)@@ -98,39 +97,6 @@ func (c *PhysicalBackupController) GetBackups(ctx *gin.Context) {ctx.JSON(http.StatusOK, response)}-// GetNextScheduledBackups-// @Summary Get the next scheduled backups of a physical database-// @Description Get when the scheduler will start the next automatic full and incremental backups. A field is null when no such automatic backup will run.-// @Tags backups-physical-// @Produce json-// @Security BearerAuth-// @Param id path string true "Database ID"-// @Success 200 {object} backups_dto_physical.GetNextScheduledBackupsResponse-// @Failure 400 {object} map[string]string-// @Failure 401 {object} map[string]string-// @Router /backups/physical/database/{id}/next-backups [get]-func (c *PhysicalBackupController) GetNextScheduledBackups(ctx *gin.Context) {- user, ok := users_middleware.GetUserFromContext(ctx)- if !ok {- ctx.JSON(http.StatusUnauthorized, gin.H{"error": "User not authenticated"})- return- }-- databaseID, err := uuid.Parse(ctx.Param("id"))- if err != nil {- ctx.JSON(http.StatusBadRequest, gin.H{"error": "invalid database ID"})- return- }-- response, err := c.physicalBackupService.GetNextScheduledBackups(ctx.Request.Context(), user, databaseID)- if err != nil {- ctx.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})- return- }-- ctx.JSON(http.StatusOK, response)-}-// TriggerBackup// @Summary Trigger a physical backup// @Description Requests an out-of-cadence backup, honored on the scheduler's next tick. type=full forces a new full; type=incremental extends the current chain (409 if none); type=auto lets the scheduler pick.diff --git a/backend/internal/features/backups/backups/controllers/physical/controller_test.go b/backend/internal/features/backups/backups/controllers/physical/controller_test.goindex dd11eb96..0a297143 100644--- a/backend/internal/features/backups/backups/controllers/physical/controller_test.go+++ b/backend/internal/features/backups/backups/controllers/physical/controller_test.go@@ -7,7 +7,6 @@ import ("encoding/json""io""net/http"- "strconv""strings""testing""time"@@ -18,7 +17,6 @@ import ("github.com/stretchr/testify/assert""github.com/stretchr/testify/require"- "databasus-backend/internal/config"audit_logs "databasus-backend/internal/features/audit_logs"backuping_physical "databasus-backend/internal/features/backups/backups/backuping/physical"backups_controllers_physical "databasus-backend/internal/features/backups/backups/controllers/physical"@@ -31,8 +29,6 @@ import (backups_dto_physical "databasus-backend/internal/features/backups/backups/dto/physical"backups_config_physical "databasus-backend/internal/features/backups/config/physical""databasus-backend/internal/features/databases"- postgresql_physical "databasus-backend/internal/features/databases/databases/postgresql/physical"- "databasus-backend/internal/features/intervals""databasus-backend/internal/features/notifiers""databasus-backend/internal/features/storages"users_dto "databasus-backend/internal/features/users/dto"@@ -1594,275 +1590,3 @@ func readTarEntryNames(t *testing.T, body []byte) []string {return names}--func Test_GetNextScheduledBackups_WhenFullAndIncrementalEnabled_ReturnsBoth(t *testing.T) {- testCases := []struct {- name string- backupType postgresql_physical.BackupType- }{- {name: "full and incremental", backupType: postgresql_physical.BackupTypeFullAndIncremental},- {- name: "full, incremental and WAL stream",- backupType: postgresql_physical.BackupTypeFullIncrementalAndWalStream,- },- }-- for _, testCase := range testCases {- t.Run(testCase.name, func(t *testing.T) {- prereqs := createNextScheduledBackupsPrereqs(t, testCase.backupType)- saveNextScheduledBackupsTestConfig(t, prereqs, &prereqs.storage.ID)-- lastFullTime := time.Now().UTC().Add(-2 * time.Hour).Truncate(time.Second)- lastIncrementalTime := time.Now().UTC().Add(-20 * time.Minute).Truncate(time.Second)- full := createNextScheduledBackupsTestFull(- t, prereqs, physical_enums.PhysicalBackupStatusCompleted, lastFullTime)- createNextScheduledBackupsTestIncremental(- t, prereqs, full.ID, physical_enums.PhysicalBackupStatusCompleted, lastIncrementalTime)-- response := getNextScheduledBackups(t, prereqs, prereqs.user.Token)-- require.NotNil(t, response.NextFullBackup)- assert.False(t, response.NextFullBackup.IsDue)- require.NotNil(t, response.NextIncrementalBackup)- assert.False(t, response.NextIncrementalBackup.IsDue)- assert.True(t, lastIncrementalTime.Add(time.Hour).Equal(response.NextIncrementalBackup.ScheduledAt),- "next incremental backup %s, reported %s",- lastIncrementalTime.Add(time.Hour), response.NextIncrementalBackup.ScheduledAt)- })- }-}--func Test_GetNextScheduledBackups_WhenFullOnly_ReturnsNoIncremental(t *testing.T) {- prereqs := createNextScheduledBackupsPrereqs(t, postgresql_physical.BackupTypeFullOnly)- saveNextScheduledBackupsTestConfig(t, prereqs, &prereqs.storage.ID)-- response := getNextScheduledBackups(t, prereqs, prereqs.user.Token)-- require.NotNil(t, response.NextFullBackup)- assert.True(t, response.NextFullBackup.IsDue)- assert.Nil(t, response.NextIncrementalBackup)-}--func Test_GetNextScheduledBackups_WhenAutomaticBackupsWillNotRun_ReturnsNeither(t *testing.T) {- t.Run("backups disabled", func(t *testing.T) {- prereqs := createNextScheduledBackupsPrereqs(t, postgresql_physical.BackupTypeFullAndIncremental)- backupConfig := saveNextScheduledBackupsTestConfig(t, prereqs, &prereqs.storage.ID)-- backupConfig.IsBackupsEnabled = false- _, err := backups_config_physical.GetBackupConfigService().SaveBackupConfig(t.Context(), backupConfig)- require.NoError(t, err)-- assertNoNextScheduledBackups(t, getNextScheduledBackups(t, prereqs, prereqs.user.Token))- })-- t.Run("storage missing", func(t *testing.T) {- prereqs := createNextScheduledBackupsPrereqs(t, postgresql_physical.BackupTypeFullAndIncremental)- saveNextScheduledBackupsTestConfig(t, prereqs, nil)-- assertNoNextScheduledBackups(t, getNextScheduledBackups(t, prereqs, prereqs.user.Token))- })-- t.Run("backup config never saved", func(t *testing.T) {- prereqs := createNextScheduledBackupsPrereqs(t, postgresql_physical.BackupTypeFullAndIncremental)-- assertNoNextScheduledBackups(t, getNextScheduledBackups(t, prereqs, prereqs.user.Token))-- backupConfig, err := backups_config_physical.GetBackupConfigService().FindBackupConfigByDbId(- prereqs.database.ID)- require.NoError(t, err)- assert.Nil(t, backupConfig)- })-- t.Run("system identifier mismatch unresolved", func(t *testing.T) {- prereqs := createNextScheduledBackupsPrereqs(t, postgresql_physical.BackupTypeFullAndIncremental)- saveNextScheduledBackupsTestConfig(t, prereqs, &prereqs.storage.ID)-- mismatchedFull := createNextScheduledBackupsTestFull(- t, prereqs, physical_enums.PhysicalBackupStatusError, time.Now().UTC().Add(-time.Hour))- mismatchedFull.ErrorReason = new(physical_enums.PhysicalBackupErrorSystemIdentifierMismatch)- require.NoError(t, physical_repositories.GetFullBackupRepository().Save(mismatchedFull))-- assertNoNextScheduledBackups(t, getNextScheduledBackups(t, prereqs, prereqs.user.Token))- })-}--func Test_GetNextScheduledBackups_WhenIncrementalChainIsHeldBack_ReturnsFullOnly(t *testing.T) {- t.Run("chain broken by WAL summarization off", func(t *testing.T) {- prereqs := createNextScheduledBackupsPrereqs(t, postgresql_physical.BackupTypeFullAndIncremental)- saveNextScheduledBackupsTestConfig(t, prereqs, &prereqs.storage.ID)-- full := createNextScheduledBackupsTestFull(- t, prereqs, physical_enums.PhysicalBackupStatusCompleted, time.Now().UTC().Add(-2*time.Hour))- brokenIncremental := createNextScheduledBackupsTestIncremental(- t, prereqs, full.ID, physical_enums.PhysicalBackupStatusChainBroken, time.Now().UTC().Add(-time.Hour))- brokenIncremental.ErrorReason = new(physical_enums.PhysicalBackupErrorSummarizerOff)- require.NoError(t, physical_repositories.GetIncrementalBackupRepository().Save(brokenIncremental))-- response := getNextScheduledBackups(t, prereqs, prereqs.user.Token)-- assert.NotNil(t, response.NextFullBackup)- assert.Nil(t, response.NextIncrementalBackup)- })-- t.Run("no completed full among the newest attempts", func(t *testing.T) {- prereqs := createNextScheduledBackupsPrereqs(t, postgresql_physical.BackupTypeFullAndIncremental)- saveNextScheduledBackupsTestConfig(t, prereqs, &prereqs.storage.ID)-- createNextScheduledBackupsTestFull(- t, prereqs, physical_enums.PhysicalBackupStatusError, time.Now().UTC().Add(-2*time.Hour))-- response := getNextScheduledBackups(t, prereqs, prereqs.user.Token)-- assert.NotNil(t, response.NextFullBackup)- assert.Nil(t, response.NextIncrementalBackup)- })-}--func Test_GetNextScheduledBackups_WhenDatabaseIsLogical_ReturnsBadRequest(t *testing.T) {- prereqs := createPhysicalControllerPrereqs(t)- logicalDatabase := databases.CreateTestDatabase(prereqs.workspace.ID, prereqs.storage, prereqs.notifier)- t.Cleanup(func() { databases.RemoveTestDatabase(t.Context(), logicalDatabase) })-- response := test_utils.MakeGetRequest(t, prereqs.router,- "/api/v1/backups/physical/database/"+logicalDatabase.ID.String()+"/next-backups",- "Bearer "+prereqs.user.Token, http.StatusBadRequest)-- assert.Contains(t, string(response.Body), "logical backups")-}--func Test_GetNextScheduledBackups_PermissionsEnforced(t *testing.T) {- prereqs := createPhysicalControllerPrereqs(t)- saveNextScheduledBackupsTestConfig(t, prereqs, &prereqs.storage.ID)-- nextBackupsURL := "/api/v1/backups/physical/database/" + prereqs.database.ID.String() + "/next-backups"-- runRolePermissionMatrix(t, prereqs, false, http.StatusOK, func(authHeader string) int {- return workspaces_testing.MakeAPIRequest(prereqs.router, "GET", nextBackupsURL, authHeader, nil).Code- })-- nonMember := users_testing.CreateTestUser(t.Context(), users_enums.UserRoleMember)- response := test_utils.MakeGetRequest(t, prereqs.router, nextBackupsURL,- "Bearer "+nonMember.Token, http.StatusBadRequest)- assert.Contains(t, string(response.Body), "insufficient permissions")- assert.NotContains(t, string(response.Body), "nextFullBackup")-}--func Test_GetNextScheduledBackups_WhenRequestIsUnauthenticated_ReturnsUnauthorized(t *testing.T) {- router := newPhysicalControllerRouter()-- test_utils.MakeGetRequest(t, router,- "/api/v1/backups/physical/database/"+uuid.NewString()+"/next-backups",- "", http.StatusUnauthorized)-}--func createNextScheduledBackupsPrereqs(- t *testing.T,- backupType postgresql_physical.BackupType,-) *physicalControllerPrereqs {- t.Helper()-- prereqs := createPhysicalControllerPrereqs(t)-- port, err := strconv.Atoi(config.GetEnv().TestPhysicalPostgres17Port)- require.NoError(t, err)-- database := databases.CreateTestPhysicalPostgresDatabaseWithType(- config.GetEnv().TestLocalhost, port, prereqs.workspace.ID, prereqs.notifier, "17", backupType)- t.Cleanup(func() {- physical_testing.DeleteAllPhysicalCatalogForDatabase(t, database.ID)- databases.RemoveTestDatabase(t.Context(), database)- })-- prereqs.database = database-- return prereqs-}--func saveNextScheduledBackupsTestConfig(- t *testing.T,- prereqs *physicalControllerPrereqs,- storageID *uuid.UUID,-) *backups_config_physical.PhysicalBackupConfig {- t.Helper()-- configService := backups_config_physical.GetBackupConfigService()-- backupConfig, err := configService.GetBackupConfigByDbId(prereqs.database.ID)- require.NoError(t, err)-- backupConfig.IsBackupsEnabled = true- backupConfig.StorageID = storageID- backupConfig.Storage = nil- backupConfig.FullBackupInterval = intervals.Interval{- Type: intervals.IntervalWeekly,- TimeOfDay: new("03:00"),- Weekday: new(int(time.Now().UTC().AddDate(0, 0, 3).Weekday())),- }- if backupConfig.PostgresqlPhysical.BackupType != postgresql_physical.BackupTypeFullOnly {- backupConfig.IncrementalBackupInterval = intervals.Interval{Type: intervals.IntervalHourly}- }-- savedConfig, err := configService.SaveBackupConfig(t.Context(), backupConfig)- require.NoError(t, err)-- return savedConfig-}--func createNextScheduledBackupsTestFull(- t *testing.T,- prereqs *physicalControllerPrereqs,- status physical_enums.PhysicalBackupStatus,- createdAt time.Time,-) *physical_models.PhysicalFullBackup {- t.Helper()-- full := physical_testing.NewTestCompletedFullBackup(- prereqs.database.ID, prereqs.storage.ID, 1, walmath.LSN(0), walmath.LSN(segmentBytes))- full.Status = status- full.CreatedAt = createdAt-- return physical_testing.CreateTestFullBackup(t, full)-}--func createNextScheduledBackupsTestIncremental(- t *testing.T,- prereqs *physicalControllerPrereqs,- rootFullBackupID uuid.UUID,- status physical_enums.PhysicalBackupStatus,- createdAt time.Time,-) *physical_models.PhysicalIncrementalBackup {- t.Helper()-- incremental := physical_testing.NewTestCompletedIncrementalBackup(- prereqs.database.ID, prereqs.storage.ID, rootFullBackupID, nil, 1,- walmath.LSN(segmentBytes), walmath.LSN(2*segmentBytes))- incremental.Status = status- incremental.CreatedAt = createdAt-- return physical_testing.CreateTestIncrementalBackup(t, incremental)-}--func getNextScheduledBackups(- t *testing.T,- prereqs *physicalControllerPrereqs,- token string,-) *backups_dto_physical.GetNextScheduledBackupsResponse {- t.Helper()-- var response backups_dto_physical.GetNextScheduledBackupsResponse- test_utils.MakeGetRequestAndUnmarshal(t, prereqs.router,- "/api/v1/backups/physical/database/"+prereqs.database.ID.String()+"/next-backups",- "Bearer "+token, http.StatusOK, &response)-- return &response-}--func assertNoNextScheduledBackups(- t *testing.T,- response *backups_dto_physical.GetNextScheduledBackupsResponse,-) {- t.Helper()-- assert.Nil(t, response.NextFullBackup)- assert.Nil(t, response.NextIncrementalBackup)-}diff --git a/backend/internal/features/backups/backups/dto/logical/dto.go b/backend/internal/features/backups/backups/dto/logical/dto.goindex 18f45cb4..f6c37e31 100644--- a/backend/internal/features/backups/backups/dto/logical/dto.go+++ b/backend/internal/features/backups/backups/dto/logical/dto.go@@ -8,7 +8,6 @@ import (backups_core_logical "databasus-backend/internal/features/backups/backups/core/logical""databasus-backend/internal/features/backups/backups/encryption"- "databasus-backend/internal/features/intervals")type GetBackupsRequest struct {@@ -26,10 +25,6 @@ type GetBackupsResponse struct {Offset int `json:"offset"`}-type GetNextScheduledBackupResponse struct {- NextBackup *intervals.NextTrigger `json:"nextBackup"`-}-type DecryptionReaderCloser struct {*encryption.DecryptionReaderBaseReader io.ReadCloserdiff --git a/backend/internal/features/backups/backups/dto/physical/dto.go b/backend/internal/features/backups/backups/dto/physical/dto.goindex b6bf12ec..fd3bae6b 100644--- a/backend/internal/features/backups/backups/dto/physical/dto.go+++ b/backend/internal/features/backups/backups/dto/physical/dto.go@@ -6,7 +6,6 @@ import ("github.com/google/uuid"physical_enums "databasus-backend/internal/features/backups/backups/core/physical/enums"- "databasus-backend/internal/features/intervals")// PhysicalBackupListItem is one row of the flat physical-backup list: a FULL, an@@ -91,8 +90,3 @@ type GenerateRestoreTokenResponse struct {Token string `json:"token"`URL string `json:"url"`}--type GetNextScheduledBackupsResponse struct {- NextFullBackup *intervals.NextTrigger `json:"nextFullBackup"`- NextIncrementalBackup *intervals.NextTrigger `json:"nextIncrementalBackup"`-}diff --git a/backend/internal/features/backups/backups/services/di.go b/backend/internal/features/backups/backups/services/di.goindex aa041c54..09dd3911 100644--- a/backend/internal/features/backups/backups/services/di.go+++ b/backend/internal/features/backups/backups/services/di.go@@ -61,7 +61,6 @@ var physicalBackupService = &PhysicalBackupService{physical_repositories.GetWalSegmentRepository(),physical_repositories.GetInFlightBackupRepository(),backuping_physical.GetPhysicalBackupCanceller(),- backuping_physical.GetPhysicalBackupsScheduler(),backups_download.GetRestoreStreamWriter(),backups_download.GetRestoreTokenService(),encryption_secrets.GetSecretKeyService(),diff --git a/backend/internal/features/backups/backups/services/logical_service.go b/backend/internal/features/backups/backups/services/logical_service.goindex 2645f70b..b5f55131 100644--- a/backend/internal/features/backups/backups/services/logical_service.go+++ b/backend/internal/features/backups/backups/services/logical_service.go@@ -129,28 +129,6 @@ func (s *LogicalBackupService) MakeBackupWithAuth(return nil}-func (s *LogicalBackupService) GetNextScheduledBackup(- ctx context.Context,- user *users_models.User,- databaseID uuid.UUID,-) (*backups_dto_logical.GetNextScheduledBackupResponse, error) {- database, err := s.databaseService.GetDatabase(ctx, user, databaseID)- if err != nil {- return nil, err- }-- if database.Type == databases.DatabaseTypePostgresPhysical {- return nil, errors.New("database uses physical backups")- }-- nextBackup, err := s.backupSchedulerService.GetNextScheduledBackup(databaseID, time.Now().UTC())- if err != nil {- return nil, err- }-- return &backups_dto_logical.GetNextScheduledBackupResponse{NextBackup: nextBackup}, nil-}-func (s *LogicalBackupService) GetBackups(ctx context.Context,user *users_models.User,diff --git a/backend/internal/features/backups/backups/services/physical_service.go b/backend/internal/features/backups/backups/services/physical_service.goindex 60a7157d..21c74122 100644--- a/backend/internal/features/backups/backups/services/physical_service.go+++ b/backend/internal/features/backups/backups/services/physical_service.go@@ -63,7 +63,6 @@ type PhysicalBackupService struct {walSegmentRepository *physical_repositories.PhysicalWalSegmentRepositoryinFlightBackupRepository *physical_repositories.PhysicalInFlightBackupRepositorycanceller *backuping_physical.PhysicalBackupCanceller- scheduler *backuping_physical.PhysicalBackupsSchedulerrestoreStreamWriter *restore_stream.WriterrestoreTokenService *restore_token.ServicesecretKeyService *encryption_secrets.SecretKeyService@@ -71,32 +70,6 @@ type PhysicalBackupService struct {logger *slog.Logger}-func (s *PhysicalBackupService) GetNextScheduledBackups(- ctx context.Context,- user *users_models.User,- databaseID uuid.UUID,-) (*backups_dto_physical.GetNextScheduledBackupsResponse, error) {- database, err := s.databaseService.GetDatabase(ctx, user, databaseID)- if err != nil {- return nil, err- }-- if database.Type != databases.DatabaseTypePostgresPhysical {- return nil, errors.New("database uses logical backups")- }-- nextFullBackup, nextIncrementalBackup, err := s.scheduler.GetNextScheduledBackups(- databaseID, time.Now().UTC())- if err != nil {- return nil, err- }-- return &backups_dto_physical.GetNextScheduledBackupsResponse{- NextFullBackup: nextFullBackup,- NextIncrementalBackup: nextIncrementalBackup,- }, nil-}-// GetBackups returns one page of a database's backups — FULLs, incrementals and// WAL ranges of consecutive committed segments — as one flat list sorted// newest-first. It pages by keyset cursor rather than offset because the newestdiff --git a/backend/internal/features/backups/config/logical/service.go b/backend/internal/features/backups/config/logical/service.goindex 822b1b90..f4f1bbef 100644--- a/backend/internal/features/backups/config/logical/service.go+++ b/backend/internal/features/backups/config/logical/service.go@@ -145,14 +145,6 @@ func (s *BackupConfigService) GetBackupConfigByDbId(return config, nil}-// FindBackupConfigByDbId returns nil when the database has no saved backup config,-// unlike GetBackupConfigByDbId, which creates a default one.-func (s *BackupConfigService) FindBackupConfigByDbId(- databaseID uuid.UUID,-) (*LogicalBackupConfig, error) {- return s.backupConfigRepository.FindByDatabaseID(databaseID)-}-func (s *BackupConfigService) IsStorageInUse(ctx context.Context,user *users_models.User,diff --git a/backend/internal/features/backups/config/physical/service.go b/backend/internal/features/backups/config/physical/service.goindex 8495adb8..0d5d1fe3 100644--- a/backend/internal/features/backups/config/physical/service.go+++ b/backend/internal/features/backups/config/physical/service.go@@ -189,14 +189,6 @@ func (s *BackupConfigService) GetBackupConfigByDbId(return config, nil}-// FindBackupConfigByDbId returns nil when the database has no saved backup config,-// unlike GetBackupConfigByDbId, which creates a default one.-func (s *BackupConfigService) FindBackupConfigByDbId(- databaseID uuid.UUID,-) (*PhysicalBackupConfig, error) {- return s.backupConfigRepository.FindByDatabaseID(databaseID)-}-func (s *BackupConfigService) IsStorageInUse(ctx context.Context,user *users_models.User,diff --git a/backend/internal/features/intervals/dto.go b/backend/internal/features/intervals/dto.godeleted file mode 100644index 83d68a6a..00000000--- a/backend/internal/features/intervals/dto.go+++ /dev/null@@ -1,10 +0,0 @@-package intervals--import "time"--// NextTrigger is the moment the scheduler will first treat a backup as due.-// When IsDue is set, the backup is due already and ScheduledAt is the moment of the check.-type NextTrigger struct {- ScheduledAt time.Time `json:"scheduledAt"`- IsDue bool `json:"isDue"`-}diff --git a/backend/internal/features/intervals/model.go b/backend/internal/features/intervals/model.goindex daa2a59f..1d06c8f9 100644--- a/backend/internal/features/intervals/model.go+++ b/backend/internal/features/intervals/model.go@@ -91,39 +91,6 @@ func (i *Interval) ShouldTriggerBackup(now time.Time, lastBackupTime *time.Time)}}-// GetNextTrigger reports when the scheduler will first treat a backup as due.-// Returns nil when the interval cannot be evaluated. Passing Validate is what lets-// the next*Trigger helpers dereference fields and ignore parse errors.-func (i *Interval) GetNextTrigger(now time.Time, lastBackupTime *time.Time) *NextTrigger {- if i.Validate() != nil {- return nil- }-- if i.ShouldTriggerBackup(now, lastBackupTime) {- return &NextTrigger{ScheduledAt: now, IsDue: true}- }-- switch i.Type {- case IntervalHourly:- return &NextTrigger{ScheduledAt: lastBackupTime.Add(time.Hour)}-- case IntervalDaily:- return &NextTrigger{ScheduledAt: i.nextDailyTrigger(now)}-- case IntervalWeekly:- return &NextTrigger{ScheduledAt: i.nextWeeklyTrigger(now)}-- case IntervalMonthly:- return &NextTrigger{ScheduledAt: i.nextMonthlyTrigger(now)}-- case IntervalCron:- return i.nextCronTrigger(*lastBackupTime)-- default:- return nil- }-}-// ApproxPeriod returns a coarse cadence for the interval, used only where an// exact next-trigger is unnecessary (e.g. sizing a bounded wait window as a// fraction of the cadence). Cron and unknown types return 0 so callers fall@@ -154,89 +121,117 @@ func (i *Interval) Copy() Interval {}}-// A missed slot is caught up: the backup fires on the first check after it.+// daily trigger: honour the TimeOfDay slot and catch up the previous onefunc (i *Interval) shouldTriggerDaily(now, lastBackup time.Time) bool {if i.TimeOfDay == nil {return !isSameDay(lastBackup, now)}- todaySlot, isParsed := i.getTodaySlot(now)- if !isParsed {+ t, err := time.Parse("15:04", *i.TimeOfDay)+ if err != nil {return false // malformed ⇒ play safe}- latestSlot := todaySlot- if now.Before(todaySlot) {- latestSlot = todaySlot.AddDate(0, 0, -1)+ // Today's scheduled slot (todayTgt)+ todayTgt := time.Date(+ now.Year(), now.Month(), now.Day(),+ t.Hour(), t.Minute(), 0, 0, now.Location(),+ )++ // The last scheduled slot that should already have happened+ var lastScheduled time.Time+ if now.Before(todayTgt) {+ lastScheduled = todayTgt.AddDate(0, 0, -1)+ } else {+ lastScheduled = todayTgt}- return !now.Before(latestSlot) && lastBackup.Before(latestSlot)+ // Fire when we are past that slot AND no backup has been taken since it+ return (now.After(lastScheduled) || now.Equal(lastScheduled)) &&+ lastBackup.Before(lastScheduled)}-// Only this week's slot counts, so a slot missed in an earlier week is not caught up.-// Without a weekday the interval is a plain 7 days.+// weekly trigger: on specified weekday/calendar week, otherwise ≥7 daysfunc (i *Interval) shouldTriggerWeekly(now, lastBackup time.Time) bool {- if i.Weekday == nil {- return now.Sub(lastBackup) >= 7*24*time.Hour- }-- thisWeekSlot := i.getThisWeekSlot(now)-- return !now.Before(thisWeekSlot) && lastBackup.Before(thisWeekSlot)-}--// Only this month's slot counts, so a slot missed in an earlier month is not caught up.-// A day the month lacks overflows into the next month and is never reached, so that-// month gets no backup. Without a day of month, the first check of a new month fires.-func (i *Interval) shouldTriggerMonthly(now, lastBackup time.Time) bool {- if i.DayOfMonth == nil {- return lastBackup.Before(getStartOfMonth(now))- }-- thisMonthSlot := i.getMonthSlot(now)-- return !now.Before(thisMonthSlot) && lastBackup.Before(thisMonthSlot)-}--func (i *Interval) getTodaySlot(now time.Time) (time.Time, bool) {- t, err := time.Parse("15:04", *i.TimeOfDay)- if err != nil {- return time.Time{}, false- }+ if i.Weekday != nil {+ targetWd := time.Weekday(*i.Weekday)++ // Calculate the target datetime for this week+ startOfWeek := getStartOfWeek(now)++ // Convert Go weekday to days from Monday: Sunday=6, Monday=0, Tuesday=1, ..., Saturday=5+ var daysFromMonday int+ if targetWd == time.Sunday {+ daysFromMonday = 6+ } else {+ daysFromMonday = int(targetWd) - 1+ }- return time.Date(now.Year(), now.Month(), now.Day(), t.Hour(), t.Minute(), 0, 0, now.Location()), true-}+ targetThisWeek := startOfWeek.AddDate(0, 0, daysFromMonday)++ if i.TimeOfDay != nil {+ t, err := time.Parse("15:04", *i.TimeOfDay)+ if err == nil {+ targetThisWeek = time.Date(+ targetThisWeek.Year(),+ targetThisWeek.Month(),+ targetThisWeek.Day(),+ t.Hour(),+ t.Minute(),+ 0,+ 0,+ targetThisWeek.Location(),+ )+ }+ }-// The weekly slot is at midnight when TimeOfDay is missing or malformed.-// Weekday 7 lands on Sunday like 0.-func (i *Interval) getThisWeekSlot(now time.Time) time.Time {- weekday := time.Weekday(*i.Weekday)+ // If current time is at or after the target time this week+ // and no backup has been made at or after the target time, trigger+ if now.After(targetThisWeek) || now.Equal(targetThisWeek) {+ return lastBackup.Before(targetThisWeek)+ }- daysFromMonday := int(weekday) - 1- if weekday == time.Sunday {- daysFromMonday = 6+ return false}- return i.atTimeOfDay(getStartOfWeek(now).AddDate(0, 0, daysFromMonday))+ // no Weekday: generic 7-day interval+ return now.Sub(lastBackup) >= 7*24*time.Hour}-// The monthly slot is at midnight when TimeOfDay is missing or malformed. A day the-// month lacks is normalized into the following month, like time.Date does.-func (i *Interval) getMonthSlot(month time.Time) time.Time {- return i.atTimeOfDay(time.Date(month.Year(), month.Month(), *i.DayOfMonth, 0, 0, 0, 0, month.Location()))-}+// monthly trigger: on specified day/calendar month, otherwise next calendar month+func (i *Interval) shouldTriggerMonthly(now, lastBackup time.Time) bool {+ if i.DayOfMonth != nil {+ day := *i.DayOfMonth++ // Calculate the target datetime for this month+ targetThisMonth := time.Date(now.Year(), now.Month(), day, 0, 0, 0, 0, now.Location())++ if i.TimeOfDay != nil {+ t, err := time.Parse("15:04", *i.TimeOfDay)+ if err == nil {+ targetThisMonth = time.Date(+ targetThisMonth.Year(),+ targetThisMonth.Month(),+ targetThisMonth.Day(),+ t.Hour(),+ t.Minute(),+ 0,+ 0,+ targetThisMonth.Location(),+ )+ }+ }-func (i *Interval) atTimeOfDay(day time.Time) time.Time {- if i.TimeOfDay == nil {- return day- }+ // If current time is at or after the target time this month+ // and no backup has been made at or after the target time, trigger+ if now.After(targetThisMonth) || now.Equal(targetThisMonth) {+ return lastBackup.Before(targetThisMonth)+ }- t, err := time.Parse("15:04", *i.TimeOfDay)- if err != nil {- return day+ return false}-- return time.Date(day.Year(), day.Month(), day.Day(), t.Hour(), t.Minute(), 0, 0, day.Location())+ // no DayOfMonth: if we're in a new calendar month+ return lastBackup.Before(getStartOfMonth(now))}func isSameDay(a, b time.Time) bool {@@ -257,6 +252,7 @@ func getStartOfMonth(t time.Time) time.Time {return time.Date(t.Year(), t.Month(), 1, 0, 0, 0, 0, t.Location())}+// cron trigger: check if we've passed a scheduled cron time since last backupfunc (i *Interval) shouldTriggerCron(now, lastBackup time.Time) bool {if i.CronExpression == nil || *i.CronExpression == "" {return false@@ -268,48 +264,11 @@ func (i *Interval) shouldTriggerCron(now, lastBackup time.Time) bool {return false}- return !now.Before(schedule.Next(lastBackup))-}--func (i *Interval) nextDailyTrigger(now time.Time) time.Time {- todaySlot, _ := i.getTodaySlot(now)-- if now.Before(todaySlot) {- return todaySlot- }-- return todaySlot.AddDate(0, 0, 1)-}--func (i *Interval) nextWeeklyTrigger(now time.Time) time.Time {- thisWeekSlot := i.getThisWeekSlot(now)-- if now.Before(thisWeekSlot) {- return thisWeekSlot- }-- return thisWeekSlot.AddDate(0, 0, 7)-}--// Months without the configured day are skipped, as in shouldTriggerMonthly.-func (i *Interval) nextMonthlyTrigger(now time.Time) time.Time {- for month := getStartOfMonth(now); ; month = month.AddDate(0, 1, 0) {- monthSlot := i.getMonthSlot(month)-- if monthSlot.Month() == month.Month() && monthSlot.After(now) {- return monthSlot- }- }-}--func (i *Interval) nextCronTrigger(lastBackup time.Time) *NextTrigger {- parser := cron.NewParser(cron.Minute | cron.Hour | cron.Dom | cron.Month | cron.Dow)- schedule, err := parser.Parse(*i.CronExpression)- if err != nil {- return nil- }+ // Find the next scheduled time after the last backup+ nextAfterLastBackup := schedule.Next(lastBackup)- return &NextTrigger{ScheduledAt: schedule.Next(lastBackup)}+ // If we're at or past that next scheduled time, trigger+ return now.After(nextAfterLastBackup) || now.Equal(nextAfterLastBackup)}func (i *Interval) validateCronExpression(expr string) error {diff --git a/backend/internal/features/intervals/model_test.go b/backend/internal/features/intervals/model_test.goindex ed9ac6e3..51901e16 100644--- a/backend/internal/features/intervals/model_test.go+++ b/backend/internal/features/intervals/model_test.go@@ -794,311 +794,3 @@ func TestInterval_Validate(t *testing.T) {assert.NoError(t, err)})}--func Test_GetNextTrigger_ForEveryIntervalType_MatchesShouldTriggerBackup(t *testing.T) {- testCases := []struct {- name string- interval Interval- now time.Time- lastBackupTime *time.Time- nextScheduledAt time.Time- isDueNow bool- }{- {- name: "Hourly with a recent backup",- interval: Interval{Type: IntervalHourly},- now: time.Date(2026, 1, 15, 12, 0, 0, 0, time.UTC),- lastBackupTime: new(time.Date(2026, 1, 15, 11, 30, 15, 0, time.UTC)),- nextScheduledAt: time.Date(2026, 1, 15, 12, 30, 15, 0, time.UTC),- },- {- name: "Hourly with an hour elapsed",- interval: Interval{Type: IntervalHourly},- now: time.Date(2026, 1, 15, 12, 0, 0, 0, time.UTC),- lastBackupTime: new(time.Date(2026, 1, 15, 11, 0, 0, 0, time.UTC)),- nextScheduledAt: time.Date(2026, 1, 15, 12, 0, 0, 0, time.UTC),- isDueNow: true,- },- {- name: "Daily without any backup",- interval: Interval{Type: IntervalDaily, TimeOfDay: new("03:00")},- now: time.Date(2026, 1, 15, 1, 0, 0, 0, time.UTC),- nextScheduledAt: time.Date(2026, 1, 15, 1, 0, 0, 0, time.UTC),- isDueNow: true,- },- {- name: "Daily before today's slot",- interval: Interval{Type: IntervalDaily, TimeOfDay: new("03:00")},- now: time.Date(2026, 1, 15, 1, 0, 0, 0, time.UTC),- lastBackupTime: new(time.Date(2026, 1, 14, 3, 0, 20, 0, time.UTC)),- nextScheduledAt: time.Date(2026, 1, 15, 3, 0, 0, 0, time.UTC),- },- {- name: "Daily after today's backup",- interval: Interval{Type: IntervalDaily, TimeOfDay: new("03:00")},- now: time.Date(2026, 1, 15, 10, 0, 0, 0, time.UTC),- lastBackupTime: new(time.Date(2026, 1, 15, 3, 0, 20, 0, time.UTC)),- nextScheduledAt: time.Date(2026, 1, 16, 3, 0, 0, 0, time.UTC),- },- {- name: "Daily with a missed slot",- interval: Interval{Type: IntervalDaily, TimeOfDay: new("03:00")},- now: time.Date(2026, 1, 15, 10, 0, 0, 0, time.UTC),- lastBackupTime: new(time.Date(2026, 1, 13, 3, 0, 20, 0, time.UTC)),- nextScheduledAt: time.Date(2026, 1, 15, 10, 0, 0, 0, time.UTC),- isDueNow: true,- },- {- name: "Daily exactly at the slot",- interval: Interval{Type: IntervalDaily, TimeOfDay: new("03:00")},- now: time.Date(2026, 1, 15, 3, 0, 0, 0, time.UTC),- lastBackupTime: new(time.Date(2026, 1, 14, 3, 0, 20, 0, time.UTC)),- nextScheduledAt: time.Date(2026, 1, 15, 3, 0, 0, 0, time.UTC),- isDueNow: true,- },- {- name: "Weekly before this week's slot",- interval: Interval{- Type: IntervalWeekly,- TimeOfDay: new("03:00"),- Weekday: new(int(time.Wednesday)),- },- now: time.Date(2026, 1, 13, 10, 0, 0, 0, time.UTC),- lastBackupTime: new(time.Date(2026, 1, 7, 3, 0, 20, 0, time.UTC)),- nextScheduledAt: time.Date(2026, 1, 14, 3, 0, 0, 0, time.UTC),- },- {- name: "Weekly with a slot missed in an earlier week",- interval: Interval{- Type: IntervalWeekly,- TimeOfDay: new("03:00"),- Weekday: new(int(time.Wednesday)),- },- now: time.Date(2026, 1, 13, 10, 0, 0, 0, time.UTC),- lastBackupTime: new(time.Date(2025, 12, 24, 3, 0, 20, 0, time.UTC)),- nextScheduledAt: time.Date(2026, 1, 14, 3, 0, 0, 0, time.UTC),- },- {- name: "Weekly after this week's backup",- interval: Interval{- Type: IntervalWeekly,- TimeOfDay: new("03:00"),- Weekday: new(int(time.Wednesday)),- },- now: time.Date(2026, 1, 15, 10, 0, 0, 0, time.UTC),- lastBackupTime: new(time.Date(2026, 1, 14, 3, 0, 20, 0, time.UTC)),- nextScheduledAt: time.Date(2026, 1, 21, 3, 0, 0, 0, time.UTC),- },- {- name: "Weekly with this week's slot missed",- interval: Interval{- Type: IntervalWeekly,- TimeOfDay: new("03:00"),- Weekday: new(int(time.Wednesday)),- },- now: time.Date(2026, 1, 15, 10, 0, 0, 0, time.UTC),- lastBackupTime: new(time.Date(2026, 1, 7, 3, 0, 20, 0, time.UTC)),- nextScheduledAt: time.Date(2026, 1, 15, 10, 0, 0, 0, time.UTC),- isDueNow: true,- },- {- name: "Weekly on Sunday written as 7",- interval: Interval{- Type: IntervalWeekly,- TimeOfDay: new("03:00"),- Weekday: new(7),- },- now: time.Date(2026, 1, 13, 10, 0, 0, 0, time.UTC),- lastBackupTime: new(time.Date(2026, 1, 11, 3, 0, 20, 0, time.UTC)),- nextScheduledAt: time.Date(2026, 1, 18, 3, 0, 0, 0, time.UTC),- },- {- name: "Monthly before this month's slot",- interval: Interval{- Type: IntervalMonthly,- TimeOfDay: new("08:00"),- DayOfMonth: new(10),- },- now: time.Date(2026, 1, 5, 10, 0, 0, 0, time.UTC),- lastBackupTime: new(time.Date(2025, 12, 10, 8, 0, 20, 0, time.UTC)),- nextScheduledAt: time.Date(2026, 1, 10, 8, 0, 0, 0, time.UTC),- },- {- name: "Monthly after this month's backup",- interval: Interval{- Type: IntervalMonthly,- TimeOfDay: new("08:00"),- DayOfMonth: new(10),- },- now: time.Date(2026, 1, 15, 10, 0, 0, 0, time.UTC),- lastBackupTime: new(time.Date(2026, 1, 10, 8, 0, 20, 0, time.UTC)),- nextScheduledAt: time.Date(2026, 2, 10, 8, 0, 0, 0, time.UTC),- },- {- name: "Monthly with this month's slot missed",- interval: Interval{- Type: IntervalMonthly,- TimeOfDay: new("08:00"),- DayOfMonth: new(10),- },- now: time.Date(2026, 1, 15, 10, 0, 0, 0, time.UTC),- lastBackupTime: new(time.Date(2025, 12, 10, 8, 0, 20, 0, time.UTC)),- nextScheduledAt: time.Date(2026, 1, 15, 10, 0, 0, 0, time.UTC),- isDueNow: true,- },- {- name: "Monthly on day 31 skips February",- interval: Interval{- Type: IntervalMonthly,- TimeOfDay: new("03:00"),- DayOfMonth: new(31),- },- now: time.Date(2026, 1, 31, 10, 0, 0, 0, time.UTC),- lastBackupTime: new(time.Date(2026, 1, 31, 3, 0, 20, 0, time.UTC)),- nextScheduledAt: time.Date(2026, 3, 31, 3, 0, 0, 0, time.UTC),- },- {- name: "Monthly on day 31 skips a 30-day month",- interval: Interval{- Type: IntervalMonthly,- TimeOfDay: new("03:00"),- DayOfMonth: new(31),- },- now: time.Date(2026, 4, 10, 10, 0, 0, 0, time.UTC),- lastBackupTime: new(time.Date(2026, 3, 31, 3, 0, 20, 0, time.UTC)),- nextScheduledAt: time.Date(2026, 5, 31, 3, 0, 0, 0, time.UTC),- },- {- name: "Monthly on day 30 skips February",- interval: Interval{- Type: IntervalMonthly,- TimeOfDay: new("03:00"),- DayOfMonth: new(30),- },- now: time.Date(2026, 2, 1, 10, 0, 0, 0, time.UTC),- lastBackupTime: new(time.Date(2026, 1, 30, 3, 0, 20, 0, time.UTC)),- nextScheduledAt: time.Date(2026, 3, 30, 3, 0, 0, 0, time.UTC),- },- {- name: "Monthly on day 29 skips February outside a leap year",- interval: Interval{- Type: IntervalMonthly,- TimeOfDay: new("03:00"),- DayOfMonth: new(29),- },- now: time.Date(2026, 2, 1, 10, 0, 0, 0, time.UTC),- lastBackupTime: new(time.Date(2026, 1, 29, 3, 0, 20, 0, time.UTC)),- nextScheduledAt: time.Date(2026, 3, 29, 3, 0, 0, 0, time.UTC),- },- {- name: "Monthly on day 29 keeps February in a leap year",- interval: Interval{- Type: IntervalMonthly,- TimeOfDay: new("03:00"),- DayOfMonth: new(29),- },- now: time.Date(2028, 2, 1, 10, 0, 0, 0, time.UTC),- lastBackupTime: new(time.Date(2028, 1, 29, 3, 0, 20, 0, time.UTC)),- nextScheduledAt: time.Date(2028, 2, 29, 3, 0, 0, 0, time.UTC),- },- {- name: "Cron before the next run",- interval: Interval{Type: IntervalCron, CronExpression: new("0 */6 * * *")},- now: time.Date(2026, 1, 15, 8, 0, 0, 0, time.UTC),- lastBackupTime: new(time.Date(2026, 1, 15, 6, 0, 20, 0, time.UTC)),- nextScheduledAt: time.Date(2026, 1, 15, 12, 0, 0, 0, time.UTC),- },- {- name: "Cron with a missed run",- interval: Interval{Type: IntervalCron, CronExpression: new("0 */6 * * *")},- now: time.Date(2026, 1, 15, 13, 0, 0, 0, time.UTC),- lastBackupTime: new(time.Date(2026, 1, 15, 6, 0, 20, 0, time.UTC)),- nextScheduledAt: time.Date(2026, 1, 15, 13, 0, 0, 0, time.UTC),- isDueNow: true,- },- {- name: "Cron on the 1st and 15th",- interval: Interval{Type: IntervalCron, CronExpression: new("30 4 1,15 * *")},- now: time.Date(2026, 1, 10, 10, 0, 0, 0, time.UTC),- lastBackupTime: new(time.Date(2026, 1, 1, 4, 30, 20, 0, time.UTC)),- nextScheduledAt: time.Date(2026, 1, 15, 4, 30, 0, 0, time.UTC),- },- }-- for _, testCase := range testCases {- t.Run(testCase.name, func(t *testing.T) {- require.NoError(t, testCase.interval.Validate())-- nextTrigger := testCase.interval.GetNextTrigger(testCase.now, testCase.lastBackupTime)-- require.NotNil(t, nextTrigger)- assert.Equal(t, testCase.nextScheduledAt, nextTrigger.ScheduledAt)- assert.Equal(t, testCase.isDueNow, nextTrigger.IsDue)- assertNextTriggerMatchesShouldTriggerBackup(- t, &testCase.interval, testCase.now, testCase.lastBackupTime, nextTrigger)- })- }-}--func Test_GetNextTrigger_WhenIntervalCannotBeEvaluated_ReturnsNil(t *testing.T) {- testCases := []struct {- name string- interval Interval- }{- {name: "Unknown type", interval: Interval{Type: IntervalType("UNKNOWN")}},- {name: "Daily without time of day", interval: Interval{Type: IntervalDaily}},- {name: "Daily with malformed time of day", interval: Interval{Type: IntervalDaily, TimeOfDay: new("25:99")}},- {name: "Weekly without weekday", interval: Interval{Type: IntervalWeekly, TimeOfDay: new("03:00")}},- {name: "Weekly without time of day", interval: Interval{Type: IntervalWeekly, Weekday: new(3)}},- {name: "Monthly without day of month", interval: Interval{Type: IntervalMonthly, TimeOfDay: new("03:00")}},- {name: "Monthly with day of month out of range", interval: Interval{- Type: IntervalMonthly,- TimeOfDay: new("03:00"),- DayOfMonth: new(32),- }},- {name: "Cron without expression", interval: Interval{Type: IntervalCron}},- {name: "Cron with empty expression", interval: Interval{Type: IntervalCron, CronExpression: new("")}},- {name: "Cron with unparsable expression", interval: Interval{- Type: IntervalCron,- CronExpression: new("invalid cron"),- }},- }-- now := time.Date(2026, 1, 15, 12, 0, 0, 0, time.UTC)- lastBackupTime := time.Date(2026, 1, 10, 12, 0, 0, 0, time.UTC)-- for _, testCase := range testCases {- t.Run(testCase.name, func(t *testing.T) {- assert.Nil(t, testCase.interval.GetNextTrigger(now, &lastBackupTime))- assert.Nil(t, testCase.interval.GetNextTrigger(now, nil))- })- }-}--// The scheduler acts on ShouldTriggerBackup, so a reported next trigger is only-// truthful when the due check stays false up to it and turns true exactly at it.-func assertNextTriggerMatchesShouldTriggerBackup(- t *testing.T,- interval *Interval,- now time.Time,- lastBackupTime *time.Time,- nextTrigger *NextTrigger,-) {- t.Helper()-- require.Equal(t, interval.ShouldTriggerBackup(now, lastBackupTime), nextTrigger.IsDue)-- if nextTrigger.IsDue {- require.Equal(t, now, nextTrigger.ScheduledAt)-- return- }-- for moment := now; moment.Before(nextTrigger.ScheduledAt); moment = moment.Add(time.Minute) {- require.Falsef(t, interval.ShouldTriggerBackup(moment, lastBackupTime),- "due check fired at %s, before the reported %s", moment, nextTrigger.ScheduledAt)- }-- require.False(t, interval.ShouldTriggerBackup(nextTrigger.ScheduledAt.Add(-time.Second), lastBackupTime))- require.True(t, interval.ShouldTriggerBackup(nextTrigger.ScheduledAt, lastBackupTime))-}diff --git a/frontend/src/entity/backups/logical/api/logicalBackupsApi.ts b/frontend/src/entity/backups/logical/api/logicalBackupsApi.tsindex d5915dc2..1eaad0e4 100644--- a/frontend/src/entity/backups/logical/api/logicalBackupsApi.ts+++ b/frontend/src/entity/backups/logical/api/logicalBackupsApi.ts@@ -2,7 +2,6 @@ import { getApplicationServer } from '../../../../constants';import { apiHelper } from '../../../../shared/api/apiHelper';import RequestOptions from '../../../../shared/api/RequestOptions';import type { GetLogicalBackupsResponse } from '../model/GetLogicalBackupsResponse';-import type { NextScheduledBackupResponse } from '../model/NextScheduledBackupResponse';export interface BackupsFilters {statuses?: string[];@@ -31,14 +30,6 @@ export const logicalBackupsApi = {);},- async getNextScheduledBackup(databaseId: string) {- return apiHelper.fetchGetJson<NextScheduledBackupResponse>(- `${getApplicationServer()}/api/v1/backups/database/${databaseId}/next-backup`,- undefined,- true,- );- },-async makeBackup(databaseId: string) {const requestOptions: RequestOptions = new RequestOptions();requestOptions.setBody(JSON.stringify({ database_id: databaseId }));diff --git a/frontend/src/entity/backups/logical/index.ts b/frontend/src/entity/backups/logical/index.tsindex 09827fdc..2c4055bd 100644--- a/frontend/src/entity/backups/logical/index.ts+++ b/frontend/src/entity/backups/logical/index.ts@@ -12,4 +12,3 @@ export { LOGICAL_BACKUP_STATUS_LABEL_KEYS } from './model/LogicalBackupStatusLabexport { RESTORE_VERIFICATION_STATUS_LABEL_KEYS } from './model/RestoreVerificationStatusLabelKeys';export { LOGICAL_RETENTION_POLICY_TYPE_LABEL_KEYS } from './model/LogicalRetentionPolicyTypeLabelKeys';export { LOGICAL_BACKUP_NOTIFICATION_TYPE_LABEL_KEYS } from './model/LogicalBackupNotificationTypeLabelKeys';-export type { NextScheduledBackupResponse } from './model/NextScheduledBackupResponse';diff --git a/frontend/src/entity/backups/logical/model/NextScheduledBackupResponse.ts b/frontend/src/entity/backups/logical/model/NextScheduledBackupResponse.tsdeleted file mode 100644index 22c1bf4d..00000000--- a/frontend/src/entity/backups/logical/model/NextScheduledBackupResponse.ts+++ /dev/null@@ -1,6 +0,0 @@-import type { ScheduledBackupTime } from '../../shared';--export interface NextScheduledBackupResponse {- // null when no automatic backup will run- nextBackup: ScheduledBackupTime | null;-}diff --git a/frontend/src/entity/backups/physical/api/physicalBackupsApi.ts b/frontend/src/entity/backups/physical/api/physicalBackupsApi.tsindex f4473e0d..3c701078 100644--- a/frontend/src/entity/backups/physical/api/physicalBackupsApi.ts+++ b/frontend/src/entity/backups/physical/api/physicalBackupsApi.ts@@ -2,7 +2,6 @@ import { getApplicationServer } from '../../../../constants';import { apiHelper } from '../../../../shared/api/apiHelper';import RequestOptions from '../../../../shared/api/RequestOptions';import type { GetPhysicalBackupsResponse } from '../model/GetPhysicalBackupsResponse';-import type { NextScheduledBackupsResponse } from '../model/NextScheduledBackupsResponse';import type { PhysicalBackupsFilters } from '../model/PhysicalBackupsFilters';import type { PhysicalRestoreTokenResponse } from '../model/PhysicalRestoreTokenResponse';@@ -32,14 +31,6 @@ export const physicalBackupsApi = {);},- async getNextScheduledBackups(databaseId: string) {- return apiHelper.fetchGetJson<NextScheduledBackupsResponse>(- `${getApplicationServer()}/api/v1/backups/physical/database/${databaseId}/next-backups`,- undefined,- true,- );- },-async triggerPhysicalBackup(databaseId: string, type: TriggerPhysicalBackupType) {const requestOptions: RequestOptions = new RequestOptions();requestOptions.setBody(JSON.stringify({ type }));diff --git a/frontend/src/entity/backups/physical/index.ts b/frontend/src/entity/backups/physical/index.tsindex 6699d4e4..79f3968a 100644--- a/frontend/src/entity/backups/physical/index.ts+++ b/frontend/src/entity/backups/physical/index.ts@@ -18,4 +18,3 @@ export { PHYSICAL_RETENTION_LABEL_KEYS } from './model/PhysicalRetentionLabelKeyexport { PHYSICAL_BACKUP_TYPE_LABEL_KEYS } from './model/PhysicalBackupTypeLabelKeys';export { PHYSICAL_FULL_BACKUPS_POLICY_LABEL_KEYS } from './model/PhysicalFullBackupsPolicyLabelKeys';export { PHYSICAL_BACKUP_NOTIFICATION_TYPE_LABEL_KEYS } from './model/PhysicalBackupNotificationTypeLabelKeys';-export type { NextScheduledBackupsResponse } from './model/NextScheduledBackupsResponse';diff --git a/frontend/src/entity/backups/physical/model/NextScheduledBackupsResponse.ts b/frontend/src/entity/backups/physical/model/NextScheduledBackupsResponse.tsdeleted file mode 100644index d1a5960e..00000000--- a/frontend/src/entity/backups/physical/model/NextScheduledBackupsResponse.ts+++ /dev/null@@ -1,7 +0,0 @@-import type { ScheduledBackupTime } from '../../shared';--export interface NextScheduledBackupsResponse {- // each is null when no such automatic backup will run- nextFullBackup: ScheduledBackupTime | null;- nextIncrementalBackup: ScheduledBackupTime | null;-}diff --git a/frontend/src/entity/backups/shared/index.ts b/frontend/src/entity/backups/shared/index.tsindex 112044ce..dc163900 100644--- a/frontend/src/entity/backups/shared/index.ts+++ b/frontend/src/entity/backups/shared/index.ts@@ -2,6 +2,3 @@ export { BackupEncryption } from './model/BackupEncryption';export type { TransferDatabaseRequest } from './model/TransferDatabaseRequest';export { BACKUP_ENCRYPTION_LABEL_KEYS } from './model/BackupEncryptionLabelKeys';export { BACKUP_ENCRYPTION_OPTION_LABEL_KEYS } from './model/BackupEncryptionOptionLabelKeys';-export type { ScheduledBackupTime } from './model/ScheduledBackupTime';-export { isScheduledBackupDue } from './model/isScheduledBackupDue';-export { NextScheduledBackupComponent } from './ui/NextScheduledBackupComponent';diff --git a/frontend/src/entity/backups/shared/model/ScheduledBackupTime.ts b/frontend/src/entity/backups/shared/model/ScheduledBackupTime.tsdeleted file mode 100644index 6b935cf7..00000000--- a/frontend/src/entity/backups/shared/model/ScheduledBackupTime.ts+++ /dev/null@@ -1,6 +0,0 @@-export interface ScheduledBackupTime {- scheduledAt: Date;- // set by the server when the scheduler already treats the backup as due, so a- // client clock running behind the server cannot postpone it- isDue: boolean;-}diff --git a/frontend/src/entity/backups/shared/model/isScheduledBackupDue.test.ts b/frontend/src/entity/backups/shared/model/isScheduledBackupDue.test.tsdeleted file mode 100644index 44b604f9..00000000--- a/frontend/src/entity/backups/shared/model/isScheduledBackupDue.test.ts+++ /dev/null@@ -1,35 +0,0 @@-import { describe, expect, it } from 'vitest';--import { isScheduledBackupDue } from './isScheduledBackupDue';--const now = new Date('2026-01-15T12:00:00Z');--describe('isScheduledBackupDue', () => {- it('is due when the server reports it as due, even with a future time', () => {- expect(- isScheduledBackupDue({ scheduledAt: new Date('2026-01-15T13:00:00Z'), isDue: true }, now),- ).toBe(true);- });-- it('is not due when the scheduled time is still ahead', () => {- expect(- isScheduledBackupDue({ scheduledAt: new Date('2026-01-15T12:00:01Z'), isDue: false }, now),- ).toBe(false);- });-- it('is due when the scheduled time is exactly now', () => {- expect(isScheduledBackupDue({ scheduledAt: now, isDue: false }, now)).toBe(true);- });-- it('is due when the scheduled time has passed', () => {- expect(- isScheduledBackupDue({ scheduledAt: new Date('2026-01-15T11:59:59Z'), isDue: false }, now),- ).toBe(true);- });-- it('accepts the ISO string the API actually returns', () => {- const scheduledAt = '2026-01-15T11:00:00Z' as unknown as Date;-- expect(isScheduledBackupDue({ scheduledAt, isDue: false }, now)).toBe(true);- });-});diff --git a/frontend/src/entity/backups/shared/model/isScheduledBackupDue.ts b/frontend/src/entity/backups/shared/model/isScheduledBackupDue.tsdeleted file mode 100644index 368b380b..00000000--- a/frontend/src/entity/backups/shared/model/isScheduledBackupDue.ts+++ /dev/null@@ -1,8 +0,0 @@-import dayjs from 'dayjs';--import type { ScheduledBackupTime } from './ScheduledBackupTime';--export const isScheduledBackupDue = (- scheduledBackupTime: ScheduledBackupTime,- now: Date = new Date(),-): boolean => scheduledBackupTime.isDue || !dayjs(scheduledBackupTime.scheduledAt).isAfter(now);diff --git a/frontend/src/entity/backups/shared/ui/NextScheduledBackupComponent.tsx b/frontend/src/entity/backups/shared/ui/NextScheduledBackupComponent.tsxdeleted file mode 100644index 826b301c..00000000--- a/frontend/src/entity/backups/shared/ui/NextScheduledBackupComponent.tsx+++ /dev/null@@ -1,44 +0,0 @@-import dayjs from 'dayjs';-import { useMemo } from 'react';-import { Trans, useTranslation } from 'react-i18next';--import { useLocale } from '../../../../shared/i18n';-import { getUserTimeFormat } from '../../../../shared/time';-import { isScheduledBackupDue } from '../model/isScheduledBackupDue';-import type { ScheduledBackupTime } from '../model/ScheduledBackupTime';--interface Props {- scheduledBackupTime: ScheduledBackupTime;- // a literal Tailwind class such as 'min-w-[150px]', aligning the row with the labels above- labelWidthClassName: string;-}--export const NextScheduledBackupComponent = ({- scheduledBackupTime,- labelWidthClassName,-}: Props) => {- const { t } = useTranslation();- const { formatRelativeTime } = useLocale();-- const dateTimeFormat = useMemo(() => getUserTimeFormat(), []);-- const nextBackupText = isScheduledBackupDue(scheduledBackupTime) ? (- t('backups.config.schedule.nextBackupDue')- ) : (- <Trans- i18nKey="backups.config.schedule.nextBackup"- values={{- dateTime: dayjs(scheduledBackupTime.scheduledAt).local().format(dateTimeFormat.format),- relativeTime: formatRelativeTime(scheduledBackupTime.scheduledAt),- }}- components={{ lineBreak: <br /> }}- />- );-- return (- <div className="mb-1 flex w-full items-center text-xs text-gray-600 dark:text-gray-400">- <div className={`${labelWidthClassName} pr-2`} />- <div>{nextBackupText}</div>- </div>- );-};diff --git a/frontend/src/features/backups/logical/ui/ShowLogicalBackupConfigComponent.tsx b/frontend/src/features/backups/logical/ui/ShowLogicalBackupConfigComponent.tsxindex e2e855be..207769c5 100644--- a/frontend/src/features/backups/logical/ui/ShowLogicalBackupConfigComponent.tsx+++ b/frontend/src/features/backups/logical/ui/ShowLogicalBackupConfigComponent.tsx@@ -10,13 +10,8 @@ import {type LogicalBackupConfig,LogicalRetentionPolicyType,logicalBackupConfigApi,- logicalBackupsApi,} from '../../../../entity/backups/logical';-import {- BACKUP_ENCRYPTION_LABEL_KEYS,- NextScheduledBackupComponent,- type ScheduledBackupTime,-} from '../../../../entity/backups/shared';+import { BACKUP_ENCRYPTION_LABEL_KEYS } from '../../../../entity/backups/shared';import { type Database, PERIOD_LABEL_KEYS } from '../../../../entity/databases';import {INTERVAL_TYPE_LABEL_KEYS,@@ -62,7 +57,6 @@ export const ShowLogicalBackupConfigComponent = ({ database }: Props) => {const { t } = useTranslation();const listSeparator = t('common.listSeparator');const [backupConfig, setBackupConfig] = useState<LogicalBackupConfig>();- const [nextBackup, setNextBackup] = useState<ScheduledBackupTime | null>(null);const describeGfsRetention = (config: LogicalBackupConfig): string => {const texts = getGfsRetentionTexts(config);@@ -84,9 +78,6 @@ export const ShowLogicalBackupConfigComponent = ({ database }: Props) => {logicalBackupConfigApi.getBackupConfigByDbID(database.id).then((res) => {setBackupConfig(res);});- logicalBackupsApi- .getNextScheduledBackup(database.id)- .then((response) => setNextBackup(response.nextBackup));}}, [database]);@@ -170,13 +161,6 @@ export const ShowLogicalBackupConfigComponent = ({ database }: Props) => {</div>)}- {nextBackup && (- <NextScheduledBackupComponent- scheduledBackupTime={nextBackup}- labelWidthClassName="min-w-[150px]"- />- )}-<div className="mb-1 flex w-full items-center"><div className="min-w-[150px] pr-2">{t('backups.logical.config.retryIfFailedShort')}diff --git a/frontend/src/features/backups/physical/ui/ShowPhysicalBackupConfigComponent.tsx b/frontend/src/features/backups/physical/ui/ShowPhysicalBackupConfigComponent.tsxindex 60e972b2..3ee304dd 100644--- a/frontend/src/features/backups/physical/ui/ShowPhysicalBackupConfigComponent.tsx+++ b/frontend/src/features/backups/physical/ui/ShowPhysicalBackupConfigComponent.tsx@@ -6,20 +6,14 @@ import { useTranslation } from 'react-i18next';import {type FullBackupsRetention,- type NextScheduledBackupsResponse,PHYSICAL_BACKUP_NOTIFICATION_TYPE_LABEL_KEYS,PHYSICAL_RETENTION_LABEL_KEYS,type PhysicalBackupConfig,PhysicalFullBackupsPolicy,PhysicalRetention,physicalBackupConfigApi,- physicalBackupsApi,} from '../../../../entity/backups/physical';-import {- BACKUP_ENCRYPTION_LABEL_KEYS,- NextScheduledBackupComponent,- type ScheduledBackupTime,-} from '../../../../entity/backups/shared';+import { BACKUP_ENCRYPTION_LABEL_KEYS } from '../../../../entity/backups/shared';import type { Database } from '../../../../entity/databases';import {INTERVAL_TYPE_LABEL_KEYS,@@ -66,8 +60,6 @@ export const ShowPhysicalBackupConfigComponent = ({ database }: Props): JSX.Elemconst { t } = useTranslation();const listSeparator = t('common.listSeparator');const [backupConfig, setBackupConfig] = useState<PhysicalBackupConfig>();- const [nextScheduledBackups, setNextScheduledBackups] =- useState<NextScheduledBackupsResponse | null>(null);const describeGfsRetention = (retention: FullBackupsRetention): string => {const texts = getGfsRetentionTexts(retention);@@ -82,11 +74,7 @@ export const ShowPhysicalBackupConfigComponent = ({ database }: Props): JSX.Elem}, []);// Time of day, weekday and day of month are stored in UTC and shown in local time.- const renderInterval = (- label: string,- interval: Interval | undefined,- nextScheduledBackup: ScheduledBackupTime | null | undefined,- ): JSX.Element | null => {+ const renderInterval = (label: string, interval?: Interval): JSX.Element | null => {if (!interval?.type) return null;const localTime = interval.timeOfDay@@ -140,13 +128,6 @@ export const ShowPhysicalBackupConfigComponent = ({ database }: Props): JSX.Elem<div>{formattedTime}</div></div>)}-- {nextScheduledBackup && (- <NextScheduledBackupComponent- scheduledBackupTime={nextScheduledBackup}- labelWidthClassName="min-w-[180px]"- />- )}</>);};@@ -156,7 +137,6 @@ export const ShowPhysicalBackupConfigComponent = ({ database }: Props): JSX.ElemphysicalBackupConfigApi.getPhysicalBackupConfigByDbId(database.id).then((config) => {setBackupConfig(config);});- physicalBackupsApi.getNextScheduledBackups(database.id).then(setNextScheduledBackups);}}, [database]);@@ -188,12 +168,10 @@ export const ShowPhysicalBackupConfigComponent = ({ database }: Props): JSX.Elem{renderInterval(t('backups.physical.config.fullBackupCadence'),backupConfig.fullBackupInterval,- nextScheduledBackups?.nextFullBackup,)}{renderInterval(t('backups.physical.config.incrementalBackupCadence'),backupConfig.incrementalBackupInterval,- nextScheduledBackups?.nextIncrementalBackup,)}<div className="mt-4 mb-1 flex w-full items-center">diff --git a/frontend/src/features/databases/ui/DatabaseCardComponent.tsx b/frontend/src/features/databases/ui/DatabaseCardComponent.tsxindex 0ef0026a..daf379a2 100644--- a/frontend/src/features/databases/ui/DatabaseCardComponent.tsx+++ b/frontend/src/features/databases/ui/DatabaseCardComponent.tsx@@ -2,19 +2,13 @@ import { InfoCircleOutlined } from '@ant-design/icons';import { useEffect, useState } from 'react';import { Trans, useTranslation } from 'react-i18next';-import { logicalBackupConfigApi, logicalBackupsApi } from '../../../entity/backups/logical';-import { physicalBackupConfigApi, physicalBackupsApi } from '../../../entity/backups/physical';-import { type ScheduledBackupTime, isScheduledBackupDue } from '../../../entity/backups/shared';+import { logicalBackupConfigApi } from '../../../entity/backups/logical';+import { physicalBackupConfigApi } from '../../../entity/backups/physical';import { type Database, DatabaseType, HEALTH_STATUS_LABEL_KEYS } from '../../../entity/databases';import { HealthStatus } from '../../../entity/databases/model/HealthStatus';import type { Storage } from '../../../entity/storages';import { getStorageLogoFromType } from '../../../entity/storages/models/getStorageLogoFromType';-import { type TranslationKey, useLocale } from '../../../shared/i18n';--interface NextBackupLineKeys {- scheduledKey: TranslationKey;- dueKey: TranslationKey;-}+import { useLocale } from '../../../shared/i18n';interface Props {database: Database;@@ -30,25 +24,6 @@ export const DatabaseCardComponent = ({const { t } = useTranslation();const { formatRelativeTime } = useLocale();const [storage, setStorage] = useState<Storage | undefined>();- const [nextBackup, setNextBackup] = useState<ScheduledBackupTime | null>(null);- const [nextFullBackup, setNextFullBackup] = useState<ScheduledBackupTime | null>(null);- const [nextIncrementalBackup, setNextIncrementalBackup] = useState<ScheduledBackupTime | null>(- null,- );-- const renderNextBackupLine = (- scheduledBackupTime: ScheduledBackupTime | null,- lineKeys: NextBackupLineKeys,- ) =>- scheduledBackupTime && (- <div className="text-gray-500 dark:text-gray-400">- {isScheduledBackupDue(scheduledBackupTime)- ? t(lineKeys.dueKey)- : t(lineKeys.scheduledKey, {- relativeTime: formatRelativeTime(scheduledBackupTime.scheduledAt),- })}- </div>- );useEffect(() => {if (!database.id) return;@@ -61,25 +36,6 @@ export const DatabaseCardComponent = ({backupConfigRequest.then((config) => setStorage(config?.storage));}, [database.id, database.type]);- // Keyed on the database object, which the list replaces on every reload, so the- // next backup refreshes together with the last backup time.- useEffect(() => {- if (!database.id) return;-- if (database.type === DatabaseType.POSTGRES_PHYSICAL) {- physicalBackupsApi.getNextScheduledBackups(database.id).then((response) => {- setNextFullBackup(response.nextFullBackup);- setNextIncrementalBackup(response.nextIncrementalBackup);- });-- return;- }-- logicalBackupsApi- .getNextScheduledBackup(database.id)- .then((response) => setNextBackup(response.nextBackup));- }, [database]);-return (<divclassName={`mb-3 cursor-pointer rounded p-3 shadow ${selectedDatabaseId === database.id ? 'bg-blue-100 dark:bg-blue-800' : 'bg-white dark:bg-gray-800'}`}@@ -131,19 +87,6 @@ export const DatabaseCardComponent = ({</div>)}- {renderNextBackupLine(nextBackup, {- scheduledKey: 'databases.card.nextBackup',- dueKey: 'databases.card.nextBackupDue',- })}- {renderNextBackupLine(nextFullBackup, {- scheduledKey: 'databases.card.nextFullBackup',- dueKey: 'databases.card.nextFullBackupDue',- })}- {renderNextBackupLine(nextIncrementalBackup, {- scheduledKey: 'databases.card.nextIncrementalBackup',- dueKey: 'databases.card.nextIncrementalBackupDue',- })}-{database.lastBackupErrorMessage && (<div className="mt-1 flex items-center text-sm text-red-600 underline dark:text-red-400"><InfoCircleOutlined className="mr-1" style={{ color: 'red' }} />diff --git a/frontend/src/shared/i18n/locales/en.ts b/frontend/src/shared/i18n/locales/en.tsindex d3186518..762921c4 100644--- a/frontend/src/shared/i18n/locales/en.ts+++ b/frontend/src/shared/i18n/locales/en.ts@@ -303,12 +303,6 @@ export const en = {card: {storage: 'Storage: <storageName/>',lastBackup: 'Last backup {{relativeTime}}',- nextBackup: 'Next backup {{relativeTime}}',- nextBackupDue: 'Next backup is about to start',- nextFullBackup: 'Next full backup {{relativeTime}}',- nextFullBackupDue: 'Next full backup is about to start',- nextIncrementalBackup: 'Next incremental backup {{relativeTime}}',- nextIncrementalBackupDue: 'Next incremental backup is about to start',hasBackupError: 'Has backup error',},tabs: {@@ -1403,8 +1397,6 @@ export const en = {cronExpression: 'Cron expression (UTC)',timeOfDay: 'Time of day',nextRun: 'Next run {{time}}',- nextBackup: 'Next backup {{dateTime}}<lineBreak/>({{relativeTime}})',- nextBackupDue: 'Next backup is about to start',invalidCron: 'Invalid cron expression',cronHelp: {format: 'Cron format: minute hour day month weekday (UTC)',diff --git a/frontend/src/shared/i18n/locales/es.ts b/frontend/src/shared/i18n/locales/es.tsindex 39497b34..e11fc514 100644--- a/frontend/src/shared/i18n/locales/es.ts+++ b/frontend/src/shared/i18n/locales/es.ts@@ -310,12 +310,6 @@ export const es: typeof en = {card: {storage: 'Almacenamiento: <storageName/>',lastBackup: 'Última copia de seguridad {{relativeTime}}',- nextBackup: 'Próxima copia de seguridad {{relativeTime}}',- nextBackupDue: 'La próxima copia de seguridad está a punto de empezar',- nextFullBackup: 'Próxima copia completa {{relativeTime}}',- nextFullBackupDue: 'La próxima copia completa está a punto de empezar',- nextIncrementalBackup: 'Próxima copia incremental {{relativeTime}}',- nextIncrementalBackupDue: 'La próxima copia incremental está a punto de empezar',hasBackupError: 'Error en la copia de seguridad',},tabs: {@@ -1431,8 +1425,6 @@ export const es: typeof en = {cronExpression: 'Expresión cron (UTC)',timeOfDay: 'Hora del día',nextRun: 'Próxima ejecución: {{time}}',- nextBackup: 'Próxima copia de seguridad: {{dateTime}}<lineBreak/>({{relativeTime}})',- nextBackupDue: 'La próxima copia de seguridad está a punto de empezar',invalidCron: 'Expresión cron no válida',cronHelp: {format: 'Formato cron: minuto, hora, día, mes, día de la semana (UTC)',diff --git a/frontend/src/shared/i18n/locales/fr.ts b/frontend/src/shared/i18n/locales/fr.tsindex 99575833..f0f1a21b 100644--- a/frontend/src/shared/i18n/locales/fr.ts+++ b/frontend/src/shared/i18n/locales/fr.ts@@ -310,12 +310,6 @@ export const fr: typeof en = {card: {storage: 'Stockage : <storageName/>',lastBackup: 'Dernière sauvegarde {{relativeTime}}',- nextBackup: 'Prochaine sauvegarde {{relativeTime}}',- nextBackupDue: 'La prochaine sauvegarde va bientôt démarrer',- nextFullBackup: 'Prochaine sauvegarde complète {{relativeTime}}',- nextFullBackupDue: 'La prochaine sauvegarde complète va bientôt démarrer',- nextIncrementalBackup: 'Prochaine sauvegarde incrémentale {{relativeTime}}',- nextIncrementalBackupDue: 'La prochaine sauvegarde incrémentale va bientôt démarrer',hasBackupError: 'Erreur de sauvegarde',},tabs: {@@ -1440,8 +1434,6 @@ export const fr: typeof en = {cronExpression: 'Expression cron (UTC)',timeOfDay: 'Heure',nextRun: 'Prochaine exécution : {{time}}',- nextBackup: 'Prochaine sauvegarde : {{dateTime}}<lineBreak/>({{relativeTime}})',- nextBackupDue: 'La prochaine sauvegarde va bientôt démarrer',invalidCron: 'Expression cron non valide',cronHelp: {format: 'Format cron : minute, heure, jour, mois, jour de la semaine (UTC)',diff --git a/frontend/src/shared/i18n/locales/pt.ts b/frontend/src/shared/i18n/locales/pt.tsindex d79fae08..6bce1ee3 100644--- a/frontend/src/shared/i18n/locales/pt.ts+++ b/frontend/src/shared/i18n/locales/pt.ts@@ -309,12 +309,6 @@ export const pt: typeof en = {card: {storage: 'Armazenamento: <storageName/>',lastBackup: 'Último backup {{relativeTime}}',- nextBackup: 'Próximo backup {{relativeTime}}',- nextBackupDue: 'O próximo backup está prestes a começar',- nextFullBackup: 'Próximo backup completo {{relativeTime}}',- nextFullBackupDue: 'O próximo backup completo está prestes a começar',- nextIncrementalBackup: 'Próximo backup incremental {{relativeTime}}',- nextIncrementalBackupDue: 'O próximo backup incremental está prestes a começar',hasBackupError: 'Com erro de backup',},tabs: {@@ -1423,8 +1417,6 @@ export const pt: typeof en = {cronExpression: 'Expressão cron (UTC)',timeOfDay: 'Horário',nextRun: 'Próxima execução: {{time}}',- nextBackup: 'Próximo backup: {{dateTime}}<lineBreak/>({{relativeTime}})',- nextBackupDue: 'O próximo backup está prestes a começar',invalidCron: 'Expressão cron inválida',cronHelp: {format: 'Formato cron: minuto hora dia mês dia-da-semana (UTC)',diff --git a/frontend/src/shared/i18n/locales/ru.ts b/frontend/src/shared/i18n/locales/ru.tsindex 269634fb..b475b4fe 100644--- a/frontend/src/shared/i18n/locales/ru.ts+++ b/frontend/src/shared/i18n/locales/ru.ts@@ -304,12 +304,6 @@ export const ru: typeof en = {card: {storage: 'Хранилище: <storageName/>',lastBackup: 'Последний бекап {{relativeTime}}',- nextBackup: 'Следующий бекап {{relativeTime}}',- nextBackupDue: 'Следующий бекап вот-вот начнется',- nextFullBackup: 'Следующий полный бекап {{relativeTime}}',- nextFullBackupDue: 'Следующий полный бекап вот-вот начнется',- nextIncrementalBackup: 'Следующий инкрементальный бекап {{relativeTime}}',- nextIncrementalBackupDue: 'Следующий инкрементальный бекап вот-вот начнется',hasBackupError: 'Есть ошибка бекапа',},tabs: {@@ -1407,8 +1401,6 @@ export const ru: typeof en = {cronExpression: 'Cron-выражение (UTC)',timeOfDay: 'Время',nextRun: 'Следующий запуск: {{time}}',- nextBackup: 'Следующий бекап: {{dateTime}}<lineBreak/>({{relativeTime}})',- nextBackupDue: 'Следующий бекап вот-вот начнется',invalidCron: 'Некорректное cron-выражение',cronHelp: {format: 'Формат cron: минута, час, день, месяц, день недели (UTC)',diff --git a/frontend/src/shared/i18n/locales/zh.ts b/frontend/src/shared/i18n/locales/zh.tsindex f746baff..f935664a 100644--- a/frontend/src/shared/i18n/locales/zh.ts+++ b/frontend/src/shared/i18n/locales/zh.ts@@ -295,12 +295,6 @@ export const zh: typeof en = {card: {storage: '存储:<storageName/>',lastBackup: '上次备份:{{relativeTime}}',- nextBackup: '下次备份:{{relativeTime}}',- nextBackupDue: '下次备份即将开始',- nextFullBackup: '下次全量备份:{{relativeTime}}',- nextFullBackupDue: '下次全量备份即将开始',- nextIncrementalBackup: '下次增量备份:{{relativeTime}}',- nextIncrementalBackupDue: '下次增量备份即将开始',hasBackupError: '备份出错',},tabs: {@@ -1355,8 +1349,6 @@ export const zh: typeof en = {cronExpression: 'Cron 表达式(UTC)',timeOfDay: '时间',nextRun: '下次运行:{{time}}',- nextBackup: '下次备份:{{dateTime}}<lineBreak/>({{relativeTime}})',- nextBackupDue: '下次备份即将开始',invalidCron: '无效的 Cron 表达式',cronHelp: {format: 'Cron 格式:分钟 小时 日 月 星期(UTC)',diff --git a/openspec/changes/archive/2026-10-10-remove-next-backup-time/.openspec.yaml b/openspec/changes/archive/2026-10-10-remove-next-backup-time/.openspec.yamlnew file mode 100644index 00000000..20f6aba1--- /dev/null+++ b/openspec/changes/archive/2026-10-10-remove-next-backup-time/.openspec.yaml@@ -0,0 +1,3 @@+schema: spec-driven+created: 2026-10-10+retire_capabilities: truediff --git a/openspec/changes/archive/2026-10-10-remove-next-backup-time/design.md b/openspec/changes/archive/2026-10-10-remove-next-backup-time/design.mdnew file mode 100644index 00000000..5e2d64c4--- /dev/null+++ b/openspec/changes/archive/2026-10-10-remove-next-backup-time/design.md@@ -0,0 +1,53 @@+## Context++The feature came in as one commit, `4bb7ffa8`. Besides the new surface, that commit reworked code the feature touched:++- In `backend/internal/features/intervals/model.go` it replaced `NextTriggerTime` with `GetNextTrigger` (`model.go:97` at `HEAD`) and rewrote the `shouldTrigger*` helpers around shared slot helpers. The rewrite kept the due checks' behavior; its tests pinned `GetNextTrigger` against `ShouldTriggerBackup`.+- In the physical scheduler it extracted `getChainlessIncrementalHoldBackReason` from `decideReAnchoringFull`, so the new query and the scheduler share one hold-back check.+- In the read-only settings views it deleted the browser-computed cron "Next run" line and put the server-reported next backup line in its place.++Before that commit, `Interval.NextTriggerTime` existed with no production caller (`model.go:96` after a revert), and the read-only settings computed a cron "Next run" from the current moment (`ShowPhysicalBackupConfigComponent.tsx:101`, `ShowLogicalBackupConfigComponent.tsx:163` after a revert).++Later commits edited some of the feature's files: `2b0e5c64` reformatted `NextScheduledBackupComponent.tsx` and reordered imports in `logicalBackupsApi.ts` and `physicalBackupsApi.ts`, and `c05a682a` changed the `walRange` keys in all six dictionaries. Only the first overlaps the reverted hunks, and that file is deleted here; the other edits sit in unrelated lines, so the revert applies to them cleanly.++## Goals / Non-Goals++**Goals:**++- No next backup time anywhere in the read-only interface, the API or the backend.+- Scheduling behavior identical to the code that ran before the feature.++**Non-Goals:**++- Keeping the interval or scheduler refactors from `4bb7ffa8` for their own sake.+- Changing the cron preview in the settings editors.++## Decisions++### Revert the commit, then delete what the revert brings back++`git revert 4bb7ffa8` removes the feature together with its refactors and returns the scheduler and interval code to what ran in production before. Two pieces the revert restores are then deleted: `Interval.NextTriggerTime` with `nextDailyTrigger`, `nextWeeklyTrigger`, `nextMonthlyTrigger`, `nextCronTrigger` and their tests, and the cron "Next run" line in both read-only settings views.++Rejected: deleting the feature surface by hand and keeping the refactors. The result would be smaller, but it would be new code that never ran in a release, reviewed without the feature that justified it. `getChainlessIncrementalHoldBackReason` would be left with one caller, and the interval rewrite's tests would lose their subject, since they compare `GetNextTrigger` to the due check. A revert is checkable line by line against a known commit.++Rejected: a plain revert with nothing deleted afterwards. It restores a dead function with known wrong answers for missed slots and short months, and a "Next run" line that can disagree with the scheduler. Both contradict the decision to remove the feature.++### The editor cron preview stays++`EditLogicalBackupConfigComponent.tsx:420` and `PhysicalIntervalEditor.tsx:165` show when an expression being typed would fire. They describe an unsaved value, so there is no last backup to compute from, and their purpose is writing a correct expression. The `backups.config.schedule.nextRun` key stays for them.++Rejected: deleting the editor preview too. It is input help, not a schedule display, and the removed feature left it alone for the same reason.++### Module rules++`backend/AGENTS.md` and `frontend/AGENTS.md` apply as usual. The frontend dictionaries are typed `typeof en`, so the keys leave all six in one step, and `pnpm build` catches a leftover. The root `AGENTS.md` rule against unrequested backward compatibility means the endpoints are deleted, not kept as stubs.++## Risks / Trade-offs++- [A script outside the frontend calls the removed endpoints] -> The endpoints were added on 2026-10-10 and have not shipped in a release. Any caller gets a 404.+- [The revert conflicts with later edits] -> The only conflict is `NextScheduledBackupComponent.tsx`, which is deleted anyway. The later edits to the two API clients and the dictionaries do not overlap the reverted lines.+- [The reverted interval code differs from what the backend tests expect] -> The interval and scheduler test packages run against the reverted code before the change is done.++## Migration Plan++No data or config migration. Rolling back means reverting this change's commit, which restores the feature.diff --git a/openspec/changes/archive/2026-10-10-remove-next-backup-time/proposal.md b/openspec/changes/archive/2026-10-10-remove-next-backup-time/proposal.mdnew file mode 100644index 00000000..a429e965--- /dev/null+++ b/openspec/changes/archive/2026-10-10-remove-next-backup-time/proposal.md@@ -0,0 +1,42 @@+## Why++The next scheduled backup time, added by the `2026-10-10-show-next-backup-time` change, does not earn its place in the interface. On the database card it adds one to two lines of text to every card, and the product owner decided the feature is not needed. Removing it now, before a release ships it, avoids carrying two endpoints, a scheduler query and a spec for a display nobody asked to keep.++## What Changes++- **BREAKING** The `GET /backups/database/{id}/next-backup` and `GET /backups/physical/database/{id}/next-backups` endpoints are deleted. Only the Databasus frontend calls them, and they have not shipped in a release.+- The database card no longer shows the next backup line, and the read-only logical and physical backup settings no longer show a next backup line under each interval.+- The browser-side "Next run" line under a cron interval in the read-only backup settings is deleted as well. It predates the removed change and is computed from the current moment rather than from the last backup, so after a missed backup it names a time the scheduler will not act on. Keeping it would leave a partial and less accurate version of the removed feature.+- The backend code that only served the feature is deleted: the scheduler queries `GetNextScheduledBackup` and `GetNextScheduledBackups`, `Interval.GetNextTrigger` with its `NextTrigger` type, and the config services' `FindBackupConfigByDbId`.+- The interval code goes back to its form before the removed change, minus `Interval.NextTriggerTime` and its `next*Trigger` helpers. `NextTriggerTime` had no production caller before the removed change either, so it is deleted with its tests rather than restored.+- The interface strings for the next backup line are deleted from all six dictionaries.+- The `backup-schedule-visibility` capability is removed.++What stays:++- The cron preview in the logical and physical backup settings editors. It tells the user when an expression being typed would fire, which helps write the expression, and the removed change never touched it.+- When backups actually run. The scheduler's due checks keep their current behavior.+- The archived `2026-10-10-show-next-backup-time` change, as the record of why the feature existed.++Out of scope:++- The monthly scheduling bug on days 29, 30 and 31 that the removed change recorded. It belongs to its own change.+- The cron "Next run" line in the verification schedule settings.+- Any other indicator of upcoming backups.++## Capabilities++### New Capabilities++None.++### Modified Capabilities++- `backup-schedule-visibility`: every requirement is removed, and the capability goes with them.++## Impact++- Backend: `backend/internal/features/intervals`, the logical and physical schedulers under `backend/internal/features/backups/backups/backuping`, the backup services and controllers under `backend/internal/features/backups/backups`, and the logical and physical config services. Swagger is regenerated locally; it is not tracked.+- Frontend: the backup API clients and models in `frontend/src/entity/backups`, `DatabaseCardComponent`, `ShowLogicalBackupConfigComponent`, `ShowPhysicalBackupConfigComponent`, and the six dictionaries.+- The database card makes one request fewer per database.+- Rules this change answers to: `AGENTS.md`, `backend/AGENTS.md`, `frontend/AGENTS.md`.diff --git a/openspec/changes/archive/2026-10-10-remove-next-backup-time/specs/backup-schedule-visibility/spec.md b/openspec/changes/archive/2026-10-10-remove-next-backup-time/specs/backup-schedule-visibility/spec.mdnew file mode 100644index 00000000..d2e6f457--- /dev/null+++ b/openspec/changes/archive/2026-10-10-remove-next-backup-time/specs/backup-schedule-visibility/spec.md@@ -0,0 +1,25 @@+## REMOVED Requirements++### Requirement: The reported next backup time matches when the scheduler will act+**Reason**: The interface no longer reports a next backup time, so nothing computes one.+**Migration**: None. The feature has not shipped in a release, and only the Databasus frontend called its endpoints. Users read the schedule from the interval shown in the backup settings.++### Requirement: Physical databases report full and incremental times separately+**Reason**: Physical databases no longer report next full or incremental backup times.+**Migration**: None. The feature has not shipped in a release, and only the Databasus frontend called its endpoints. Users read the schedule from the interval shown in the backup settings.++### Requirement: No next backup is reported when automatic backups will not run+**Reason**: With no next backup time reported, there is no state in which it is withheld.+**Migration**: None. The feature has not shipped in a release, and only the Databasus frontend called its endpoints. Users read the schedule from the interval shown in the backup settings.++### Requirement: The interface shows the next backup time+**Reason**: The database card and the read-only backup settings no longer show a next backup time. The browser-computed "Next run" line under a cron interval in the read-only settings is removed with it.+**Migration**: None. The feature has not shipped in a release, and only the Databasus frontend called its endpoints. Users read the schedule from the interval shown in the backup settings.++### Requirement: A request for the wrong kind of database is rejected+**Reason**: The endpoints that reported next backup times are deleted, so there is no request to reject.+**Migration**: None. The feature has not shipped in a release, and only the Databasus frontend called its endpoints. Users read the schedule from the interval shown in the backup settings.++### Requirement: Only users who can view a database's backups can read its next backup time+**Reason**: The endpoints that reported next backup times are deleted, so there is nothing left to authorize.+**Migration**: None. The feature has not shipped in a release, and only the Databasus frontend called its endpoints. Users read the schedule from the interval shown in the backup settings.diff --git a/openspec/changes/archive/2026-10-10-remove-next-backup-time/tasks.md b/openspec/changes/archive/2026-10-10-remove-next-backup-time/tasks.mdnew file mode 100644index 00000000..0267e046--- /dev/null+++ b/openspec/changes/archive/2026-10-10-remove-next-backup-time/tasks.md@@ -0,0 +1,15 @@+## 1. Revert++- [x] 1.1 Apply `git revert --no-commit 4bb7ffa8`, delete the conflicting `NextScheduledBackupComponent.tsx`, keep `openspec/specs/backup-schedule-visibility/` and the archived `2026-10-10-show-next-backup-time` change at `HEAD`, and verify that `git grep -n "NextScheduled\|GetNextTrigger\|NextTrigger\b" -- backend/internal frontend/src` and `git grep -n "nextBackup\|nextFullBackup\|nextIncrementalBackup\|isScheduledBackupDue" -- frontend/src` find nothing++## 2. Remove what the revert restores++- [x] 2.1 Delete `Interval.NextTriggerTime`, the `next*Trigger` helpers and their tests from `backend/internal/features/intervals`, and verify with `go build ./...` and `just test-package ./internal/features/intervals/...` in `backend/`+- [x] 2.2 Delete the cron "Next run" line from `ShowLogicalBackupConfigComponent.tsx` and `ShowPhysicalBackupConfigComponent.tsx` with the imports it alone used, keep the editor previews, and verify with `pnpm typecheck` in `frontend/` and with `git grep -n "CronExpressionParser\|schedule.nextRun" -- frontend/src/features/backups`, which must list only `EditLogicalBackupConfigComponent.tsx` and `PhysicalIntervalEditor.tsx`++## 3. Verification++- [x] 3.1 Run the touched packages with `just test-package ./internal/features/intervals/... ./internal/features/backups/...` in `backend/`, which covers the intervals, scheduler, service, controller and config packages+- [x] 3.2 Run `just lint` at the root, and `pnpm test` and `pnpm build` in `frontend/`+- [x] 3.3 Regenerate the untracked swagger with `swag init -d . -g cmd/main.go -o swagger` in `backend/` and verify `grep -n "next-backup" swagger/swagger.yaml` finds nothing+- [x] 3.4 Run `openspec validate remove-next-backup-time --strict`diff --git a/openspec/specs/backup-schedule-visibility/spec.md b/openspec/specs/backup-schedule-visibility/spec.mddeleted file mode 100644index 3d417fb6..00000000--- a/openspec/specs/backup-schedule-visibility/spec.md+++ /dev/null@@ -1,156 +0,0 @@-# Backup Schedule Visibility Specification--## Purpose--Tells users when the next automatic backup of a database will run, so they can confirm a schedule is set up correctly and spot schedule or timezone mistakes without working out the next run themselves.--## Requirements--### Requirement: The reported next backup time matches when the scheduler will act--For a database with automatic backups enabled, the system SHALL report the earliest moment, at or after the current time, at which the scheduler treats a scheduled backup as due. The calculation SHALL use the same schedule rules and the same last backup the scheduler uses. That last backup is the newest one of any status, including failed and in-progress backups. When a backup is already due, the system SHALL report it as due now instead of naming a future slot.--#### Scenario: Daily schedule before today's slot--- **WHEN** a database has a daily schedule at 03:00 UTC, its last backup ran yesterday at 03:00 UTC, and the current time is 01:00 UTC-- **THEN** the system reports the next backup at 03:00 UTC today--#### Scenario: Daily schedule with a missed slot--- **WHEN** a database has a daily schedule at 03:00 UTC, its last backup ran two days ago, and the current time is 10:00 UTC-- **THEN** the system reports the backup as due now--#### Scenario: Hourly schedule counts a failed backup--- **WHEN** a database has an hourly schedule and its newest backup failed 20 minutes ago-- **THEN** the system reports the next backup one hour after that failed backup started--#### Scenario: Cron schedule--- **WHEN** a database has the cron schedule `0 */6 * * *` and its last backup ran at 06:00 UTC today, and the current time is 08:00 UTC-- **THEN** the system reports the next backup at 12:00 UTC today--#### Scenario: Weekly schedule does not catch up a previous week--- **WHEN** a database has a weekly schedule on Wednesday at 03:00 UTC, its last backup ran three weeks ago, and the current time is Tuesday-- **THEN** the system reports the next backup on Wednesday of the current week at 03:00 UTC--#### Scenario: Monthly schedule on a day the next month lacks--- **WHEN** a database has a monthly schedule on day 31 at 03:00 UTC, its last backup ran on January 31 at 03:00 UTC, and the current time is January 31 at 10:00 UTC-- **THEN** the system reports the next backup on March 31 at 03:00 UTC, because the scheduler skips months without day 31--#### Scenario: No backup exists yet--- **WHEN** a database has automatic backups enabled and no backup exists-- **THEN** the system reports the backup as due now--### Requirement: Physical databases report full and incremental times separately--For a physical database with automatic backups enabled, the system SHALL report the next full backup time from the full backup schedule. When incremental backups are enabled, the system SHALL also report the next incremental backup time from the incremental schedule. The incremental time SHALL be measured from the newest full or incremental backup. When incremental backups are disabled, the system SHALL report no incremental time. WAL streaming SHALL NOT affect either time.--#### Scenario: Full and incremental backups enabled--- **WHEN** a physical database has a weekly full schedule and an hourly incremental schedule-- **THEN** the system reports both the next full backup time and the next incremental backup time--#### Scenario: Full backups only--- **WHEN** a physical database takes full backups only-- **THEN** the system reports the next full backup time and no incremental time--#### Scenario: Incremental backups with WAL streaming--- **WHEN** a physical database takes full and incremental backups and streams WAL-- **THEN** the system reports the next full and the next incremental backup times, computed as if WAL streaming were off--### Requirement: No next backup is reported when automatic backups will not run--The system SHALL report no next backup time when automatic backups are disabled for the database, or when the database has no backup storage. For a physical database, the system SHALL also report no next backup time while automatic backups stay suspended because the database server's identity changed and the change is unresolved. The system SHALL report no next incremental backup time while incremental backups are held back. That happens when no backup chain can be extended and either the chain broke because WAL summarization was off on the server, or none of the newest full backup attempts completed. Reading the next backup time SHALL NOT create or change any backup settings.--#### Scenario: Automatic backups disabled--- **WHEN** automatic backups are disabled for a database-- **THEN** the system reports no next backup time and the interface shows no next-backup line--#### Scenario: No backup storage--- **WHEN** automatic backups are enabled for a database that has no backup storage-- **THEN** the system reports no next backup time--#### Scenario: Database without saved backup settings--- **WHEN** the next backup time is requested for a database whose backup settings were never saved-- **THEN** the system reports no next backup time and creates no backup settings--#### Scenario: Incremental backups held back after WAL summarization was off--- **WHEN** a physical database's incremental chain broke because WAL summarization was off and no chain can be extended-- **THEN** the system reports the next full backup time and no next incremental backup time--#### Scenario: Incremental backups held back after failed full backups--- **WHEN** a physical database has no extendable chain and none of its newest full backup attempts completed-- **THEN** the system reports the next full backup time and no next incremental backup time--#### Scenario: Physical backups suspended after a server identity change--- **WHEN** automatic physical backups are suspended because the database server's identity changed-- **THEN** the system reports no next full and no next incremental backup time--### Requirement: The interface shows the next backup time--The database card SHALL show the next backup time below the last backup time, as a relative time such as "in 3 hours". The read-only backup settings SHALL show the next backup time as a date and time with the relative time beside it, for every schedule type. For a physical database, they SHALL show the next full time under the full schedule and the next incremental time under the incremental schedule. A due backup SHALL read as due now. A reported time that has passed SHALL also read as due now, at the latest when the view next refreshes. The database card SHALL refresh the next backup time whenever it refreshes the last backup time. All times SHALL be displayed in the browser's local timezone, and all new text SHALL be available in every interface language.--#### Scenario: Card for a logical database--- **WHEN** a user views a logical database card whose next backup is in 3 hours-- **THEN** the card shows the last backup line and, under it, a next backup line reading "in 3 hours" in the selected language--#### Scenario: Card for a physical database--- **WHEN** a user views the card of a physical database that takes full and incremental backups-- **THEN** the card shows the next full backup time and the next incremental backup time--#### Scenario: Settings for a daily schedule--- **WHEN** a user opens the read-only backup settings of a database with a daily schedule-- **THEN** the settings show the next backup date and time in the browser's timezone, with the relative time beside it--#### Scenario: Due backup--- **WHEN** the reported next backup is due now or its time has passed-- **THEN** the interface reads it as due now instead of showing a time in the past--### Requirement: A request for the wrong kind of database is rejected--The system SHALL reject a request for a logical database's next backup time when the database is physical, and a request for a physical database's next backup times when the database is logical. The request SHALL fail as invalid instead of reporting that no backup is scheduled.--#### Scenario: Logical request for a physical database--- **WHEN** a user with access asks for the logical next backup time of a physical database-- **THEN** the system rejects the request as invalid--#### Scenario: Physical request for a logical database--- **WHEN** a user with access asks for the physical next backup times of a logical database-- **THEN** the system rejects the request as invalid--### Requirement: Only users who can view a database's backups can read its next backup time--The system SHALL return the next backup time only to a user who is allowed to view that database's backups. Any other request SHALL be rejected and SHALL NOT reveal the schedule, the next backup time, or whether automatic backups are enabled.--#### Scenario: Member of the database's workspace--- **WHEN** a user who can view the database's backups requests its next backup time-- **THEN** the system returns the next backup time--#### Scenario: User outside the database's workspace--- **WHEN** a user without access to the database's workspace requests its next backup time-- **THEN** the system rejects the request and returns no schedule information--#### Scenario: Unauthenticated request--- **WHEN** a request without a valid session asks for a database's next backup time-- **THEN** the system rejects the request as unauthenticated