PostgreSQL backup tool with Point-In-Time-Recovery and restore verification
TypeScript backupbackupsdatabasedatabase-backupdevopsdockergolangkubernetesmariadbmongodbmysqlpgpostgrespostgresqls3self-hostedsystem-administrationtoolsweb-ui
FIX (copying): Fix persisting same interval over copying
Rostislav Dugindc9ddae42efa
diff --git a/backend/cmd/main.go b/backend/cmd/main.goindex aa749dcc..ae100d5d 100644--- a/backend/cmd/main.go+++ b/backend/cmd/main.go@@ -20,7 +20,6 @@ import ("postgresus-backend/internal/features/disk"healthcheck_attempt "postgresus-backend/internal/features/healthcheck/attempt"healthcheck_config "postgresus-backend/internal/features/healthcheck/config"- postgres_monitoring_collectors "postgresus-backend/internal/features/monitoring/postgres/collectors"postgres_monitoring_metrics "postgresus-backend/internal/features/monitoring/postgres/metrics"postgres_monitoring_settings "postgresus-backend/internal/features/monitoring/postgres/settings""postgresus-backend/internal/features/notifiers"@@ -210,10 +209,6 @@ func runBackgroundTasks(log *slog.Logger) {go runWithPanicLogging(log, "postgres monitoring metrics background service", func() {postgres_monitoring_metrics.GetPostgresMonitoringMetricsBackgroundService().Run()})-- go runWithPanicLogging(log, "postgres monitoring collectors background service", func() {- postgres_monitoring_collectors.GetDbMonitoringBackgroundService().Run()- })}func runWithPanicLogging(log *slog.Logger, serviceName string, fn func()) {diff --git a/backend/internal/features/backups/config/model.go b/backend/internal/features/backups/config/model.goindex 491526ea..bf8c8e08 100644--- a/backend/internal/features/backups/config/model.go+++ b/backend/internal/features/backups/config/model.go@@ -90,3 +90,18 @@ func (b *BackupConfig) Validate() error {return nil}++func (b *BackupConfig) Copy(newDatabaseID uuid.UUID) *BackupConfig {+ return &BackupConfig{+ DatabaseID: newDatabaseID,+ IsBackupsEnabled: b.IsBackupsEnabled,+ StorePeriod: b.StorePeriod,+ BackupIntervalID: uuid.Nil,+ BackupInterval: b.BackupInterval.Copy(),+ StorageID: b.StorageID,+ SendNotificationsOn: b.SendNotificationsOn,+ IsRetryIfFailed: b.IsRetryIfFailed,+ MaxFailedTriesCount: b.MaxFailedTriesCount,+ CpuCount: b.CpuCount,+ }+}diff --git a/backend/internal/features/backups/config/service.go b/backend/internal/features/backups/config/service.goindex 8a1f69bb..71197e4a 100644--- a/backend/internal/features/backups/config/service.go+++ b/backend/internal/features/backups/config/service.go@@ -130,6 +130,20 @@ func (s *BackupConfigService) GetBackupConfigsWithEnabledBackups() ([]*BackupConreturn s.backupConfigRepository.GetWithEnabledBackups()}+func (s *BackupConfigService) OnDatabaseCopied(originalDatabaseID, newDatabaseID uuid.UUID) {+ originalConfig, err := s.GetBackupConfigByDbId(originalDatabaseID)+ if err != nil {+ return+ }++ newConfig := originalConfig.Copy(newDatabaseID)++ _, err = s.SaveBackupConfig(newConfig)+ if err != nil {+ return+ }+}+func (s *BackupConfigService) initializeDefaultConfig(databaseID uuid.UUID,) error {@@ -164,27 +178,3 @@ func storageIDsEqual(id1, id2 *uuid.UUID) bool {}return *id1 == *id2}--func (s *BackupConfigService) OnDatabaseCopied(originalDatabaseID, newDatabaseID uuid.UUID) {- originalConfig, err := s.GetBackupConfigByDbId(originalDatabaseID)- if err != nil {- return- }-- newConfig := &BackupConfig{- DatabaseID: newDatabaseID,- IsBackupsEnabled: originalConfig.IsBackupsEnabled,- StorePeriod: originalConfig.StorePeriod,- BackupIntervalID: originalConfig.BackupIntervalID,- StorageID: originalConfig.StorageID,- SendNotificationsOn: originalConfig.SendNotificationsOn,- IsRetryIfFailed: originalConfig.IsRetryIfFailed,- MaxFailedTriesCount: originalConfig.MaxFailedTriesCount,- CpuCount: originalConfig.CpuCount,- }-- _, err = s.SaveBackupConfig(newConfig)- if err != nil {- return- }-}diff --git a/backend/internal/features/intervals/model.go b/backend/internal/features/intervals/model.goindex 08c11352..91f21126 100644--- a/backend/internal/features/intervals/model.go+++ b/backend/internal/features/intervals/model.go@@ -64,6 +64,16 @@ func (i *Interval) ShouldTriggerBackup(now time.Time, lastBackupTime *time.Time)}}+func (i *Interval) Copy() *Interval {+ return &Interval{+ ID: uuid.Nil,+ Interval: i.Interval,+ TimeOfDay: i.TimeOfDay,+ Weekday: i.Weekday,+ DayOfMonth: i.DayOfMonth,+ }+}+// daily trigger: honour the TimeOfDay slot and catch up the previous onefunc (i *Interval) shouldTriggerDaily(now, lastBackup time.Time) bool {if i.TimeOfDay == nil {