diff --git a/internal/generator/backups.go b/internal/generator/backups.go index 93ce8908..0647c2db 100644 --- a/internal/generator/backups.go +++ b/internal/generator/backups.go @@ -8,8 +8,8 @@ import ( ) const ( - defaultCheckSchedule = "M H(3-6) * * 0" - defaultPruneSchedule = "M H(3-6) * * 0" + defaultCheckSchedule = "M H(5-8) * * 1" + defaultPruneSchedule = "M H(3-5) * * 0" defaultBackupSchedule = "M H(22-2) * * *" hourlyDefaultBackupRetention = 0 dailyDefaultBackupRetention = 7 @@ -104,7 +104,7 @@ func generateBackupValues( if flagCheckSchedule == "enabled" { buildValues.Backup.CheckSchedule = "@weekly-random" } else { - buildValues.Backup.CheckSchedule, err = helpers.ConvertCrontab(buildValues.Namespace, defaultCheckSchedule) + buildValues.Backup.CheckSchedule, err = helpers.ConvertCrontab(fmt.Sprintf("%s", buildValues.Namespace), defaultCheckSchedule) if err != nil { return fmt.Errorf("Unable to convert crontab for default check schedule: %v", err) } @@ -113,7 +113,7 @@ func generateBackupValues( if flagPruneSchedule == "enabled" { buildValues.Backup.PruneSchedule = "@weekly-random" } else { - buildValues.Backup.PruneSchedule, err = helpers.ConvertCrontab(buildValues.Namespace, defaultPruneSchedule) + buildValues.Backup.PruneSchedule, err = helpers.ConvertCrontab(fmt.Sprintf("%s", buildValues.Namespace), defaultPruneSchedule) if err != nil { return fmt.Errorf("Unable to convert crontab for default prune schedule: %v", err) } diff --git a/internal/generator/backups_test.go b/internal/generator/backups_test.go index cebcf261..d08d5638 100644 --- a/internal/generator/backups_test.go +++ b/internal/generator/backups_test.go @@ -43,7 +43,7 @@ func Test_generateBackupValues(t *testing.T) { Namespace: "example-com-main", Backup: BackupConfiguration{ BackupSchedule: "31 1 * * *", - CheckSchedule: "31 4 * * 0", + CheckSchedule: "31 6 * * 1", PruneSchedule: "31 4 * * 0", S3BucketName: "baas-example-project", PruneRetention: PruneRetention{ @@ -77,7 +77,7 @@ func Test_generateBackupValues(t *testing.T) { Namespace: "example-com-main", Backup: BackupConfiguration{ BackupSchedule: "1,16,31,46 23 * * 0-5", - CheckSchedule: "31 4 * * 0", + CheckSchedule: "31 6 * * 1", PruneSchedule: "31 4 * * 0", S3BucketName: "baas-example-project", PruneRetention: PruneRetention{ @@ -113,7 +113,7 @@ func Test_generateBackupValues(t *testing.T) { Namespace: "example-com-main", Backup: BackupConfiguration{ BackupSchedule: "1,16,31,46 23 * * 0-5", - CheckSchedule: "31 4 * * 0", + CheckSchedule: "31 6 * * 1", PruneSchedule: "31 4 * * 0", S3BucketName: "baas-example-project", PruneRetention: PruneRetention{ @@ -147,7 +147,7 @@ func Test_generateBackupValues(t *testing.T) { Namespace: "example-com-main", Backup: BackupConfiguration{ BackupSchedule: "1,16,31,46 23 * * 0-5", - CheckSchedule: "31 4 * * 0", + CheckSchedule: "31 6 * * 1", PruneSchedule: "31 4 * * 0", S3BucketName: "baas-example-project", PruneRetention: PruneRetention{ @@ -183,7 +183,7 @@ func Test_generateBackupValues(t *testing.T) { Namespace: "example-com-main", Backup: BackupConfiguration{ BackupSchedule: "1,16,31,46 23 * * 0-5", - CheckSchedule: "31 4 * * 0", + CheckSchedule: "31 6 * * 1", PruneSchedule: "31 4 * * 0", S3BucketName: "baas-example-project", PruneRetention: PruneRetention{ @@ -217,7 +217,7 @@ func Test_generateBackupValues(t *testing.T) { Namespace: "example-com-main", Backup: BackupConfiguration{ BackupSchedule: "1,16,31,46 23 * * 0-5", - CheckSchedule: "31 4 * * 0", + CheckSchedule: "31 6 * * 1", PruneSchedule: "31 4 * * 0", S3BucketName: "baas-example-project", PruneRetention: PruneRetention{ @@ -253,7 +253,7 @@ func Test_generateBackupValues(t *testing.T) { Namespace: "example-com-main", Backup: BackupConfiguration{ BackupSchedule: "1,16,31,46 23 * * 0-5", - CheckSchedule: "31 4 * * 0", + CheckSchedule: "31 6 * * 1", PruneSchedule: "31 4 * * 0", S3BucketName: "baas-example-project", PruneRetention: PruneRetention{ @@ -296,7 +296,7 @@ func Test_generateBackupValues(t *testing.T) { Namespace: "example-com-main", Backup: BackupConfiguration{ BackupSchedule: "1,16,31,46 0-23 1-31 1-12 0-6", - CheckSchedule: "31 4 * * 0", + CheckSchedule: "31 6 * * 1", PruneSchedule: "31 4 * * 0", S3BucketName: "baas-example-project", PruneRetention: PruneRetention{ @@ -336,7 +336,7 @@ func Test_generateBackupValues(t *testing.T) { BackupLocationSecretKey: "a1b2c3d4e5f6g7h8i9", }, BackupSchedule: "31 1 * * *", - CheckSchedule: "31 4 * * 0", + CheckSchedule: "31 6 * * 1", PruneSchedule: "31 4 * * 0", PruneRetention: PruneRetention{ Hourly: 0, @@ -378,7 +378,7 @@ func Test_generateBackupValues(t *testing.T) { BackupLocationSecretKey: "a1b2c3d4e5f6g7h8i9", }, BackupSchedule: "31 1 * * *", - CheckSchedule: "31 4 * * 0", + CheckSchedule: "31 6 * * 1", PruneSchedule: "31 4 * * 0", PruneRetention: PruneRetention{ Hourly: 0, @@ -415,7 +415,7 @@ func Test_generateBackupValues(t *testing.T) { RestoreLocationSecretKey: "a1b2c3d4e5f6g7h8i9", }, BackupSchedule: "31 1 * * *", - CheckSchedule: "31 4 * * 0", + CheckSchedule: "31 6 * * 1", PruneSchedule: "31 4 * * 0", S3BucketName: "baas-example-project", PruneRetention: PruneRetention{ @@ -462,7 +462,7 @@ func Test_generateBackupValues(t *testing.T) { RestoreLocationSecretKey: "a1b2c3d4e5f6g7h8i9", }, BackupSchedule: "31 1 * * *", - CheckSchedule: "31 4 * * 0", + CheckSchedule: "31 6 * * 1", PruneSchedule: "31 4 * * 0", PruneRetention: PruneRetention{ Hourly: 0, @@ -529,7 +529,7 @@ func Test_generateBackupValues(t *testing.T) { Namespace: "example-com-main", Backup: BackupConfiguration{ BackupSchedule: "31 1 * * *", - CheckSchedule: "31 4 * * 0", + CheckSchedule: "31 6 * * 1", PruneSchedule: "31 4 * * 0", S3BucketName: "baas-example-project", PruneRetention: PruneRetention{ @@ -566,7 +566,7 @@ func Test_generateBackupValues(t *testing.T) { Namespace: "example-com-main", Backup: BackupConfiguration{ BackupSchedule: "31 1 * * *", - CheckSchedule: "31 4 * * 0", + CheckSchedule: "31 6 * * 1", PruneSchedule: "31 4 * * 0", S3BucketName: "mybucket", PruneRetention: PruneRetention{ @@ -608,7 +608,7 @@ func Test_generateBackupValues(t *testing.T) { Namespace: "example-com-main", Backup: BackupConfiguration{ BackupSchedule: "31 1 * * *", - CheckSchedule: "31 4 * * 0", + CheckSchedule: "31 6 * * 1", PruneSchedule: "31 4 * * 0", S3BucketName: "mybucket", PruneRetention: PruneRetention{ @@ -645,7 +645,7 @@ func Test_generateBackupValues(t *testing.T) { Namespace: "example-com-main", Backup: BackupConfiguration{ BackupSchedule: "31 1 * * *", - CheckSchedule: "31 4 * * 0", + CheckSchedule: "31 6 * * 1", PruneSchedule: "31 4 * * 0", S3BucketName: "baas-cluster-bucket/baas-example-project", PruneRetention: PruneRetention{ diff --git a/test-resources/template-backups/test1-results/k8up-lagoon-backup-schedule.yaml b/test-resources/template-backups/test1-results/k8up-lagoon-backup-schedule.yaml index 6944c64e..a538603c 100644 --- a/test-resources/template-backups/test1-results/k8up-lagoon-backup-schedule.yaml +++ b/test-resources/template-backups/test1-results/k8up-lagoon-backup-schedule.yaml @@ -30,13 +30,13 @@ spec: schedule: 5 23 * * * check: resources: {} - schedule: 5 5 * * 0 + schedule: 5 7 * * 1 prune: resources: {} retention: keepDaily: 7 keepMonthly: 1 keepWeekly: 6 - schedule: 5 5 * * 0 + schedule: 5 2 * * 0 resourceRequirementsTemplate: {} status: {} diff --git a/test-resources/template-backups/test2-results/k8up-lagoon-backup-schedule.yaml b/test-resources/template-backups/test2-results/k8up-lagoon-backup-schedule.yaml index 7a3de0e9..48a9cfcb 100644 --- a/test-resources/template-backups/test2-results/k8up-lagoon-backup-schedule.yaml +++ b/test-resources/template-backups/test2-results/k8up-lagoon-backup-schedule.yaml @@ -30,13 +30,13 @@ spec: schedule: 1,31 23 * * * check: resources: {} - schedule: 5 5 * * 0 + schedule: 5 7 * * 1 prune: resources: {} retention: keepDaily: 7 keepMonthly: 1 keepWeekly: 6 - schedule: 5 5 * * 0 + schedule: 5 2 * * 0 resourceRequirementsTemplate: {} status: {} diff --git a/test-resources/template-backups/test3-results/k8up-lagoon-backup-schedule.yaml b/test-resources/template-backups/test3-results/k8up-lagoon-backup-schedule.yaml index 35be53be..ef6e4649 100644 --- a/test-resources/template-backups/test3-results/k8up-lagoon-backup-schedule.yaml +++ b/test-resources/template-backups/test3-results/k8up-lagoon-backup-schedule.yaml @@ -30,7 +30,7 @@ spec: schedule: 5 23 * * * check: resources: {} - schedule: 5 5 * * 0 + schedule: 5 7 * * 1 prune: resources: {} retention: @@ -38,6 +38,6 @@ spec: keepHourly: 10 keepMonthly: 10 keepWeekly: 10 - schedule: 5 5 * * 0 + schedule: 5 2 * * 0 resourceRequirementsTemplate: {} status: {} diff --git a/test-resources/template-backups/test4-results/k8up-lagoon-backup-schedule.yaml b/test-resources/template-backups/test4-results/k8up-lagoon-backup-schedule.yaml index 127f7099..61a03e9b 100644 --- a/test-resources/template-backups/test4-results/k8up-lagoon-backup-schedule.yaml +++ b/test-resources/template-backups/test4-results/k8up-lagoon-backup-schedule.yaml @@ -38,14 +38,14 @@ spec: schedule: 3,33 12 * * * check: resources: {} - schedule: 5 5 * * 0 + schedule: 5 7 * * 1 prune: resources: {} retention: keepDaily: 7 keepMonthly: 1 keepWeekly: 6 - schedule: 5 5 * * 0 + schedule: 5 2 * * 0 resourceRequirementsTemplate: {} status: {} --- diff --git a/test-resources/template-backups/test5-results/k8up-lagoon-backup-schedule.yaml b/test-resources/template-backups/test5-results/k8up-lagoon-backup-schedule.yaml index 836f061e..28b676b7 100644 --- a/test-resources/template-backups/test5-results/k8up-lagoon-backup-schedule.yaml +++ b/test-resources/template-backups/test5-results/k8up-lagoon-backup-schedule.yaml @@ -32,14 +32,14 @@ spec: schedule: 3,33 12 * * * check: resources: {} - schedule: 5 5 * * 0 + schedule: 5 7 * * 1 prune: resources: {} retention: keepDaily: 7 keepMonthly: 1 keepWeekly: 6 - schedule: 5 5 * * 0 + schedule: 5 2 * * 0 resourceRequirementsTemplate: {} status: {} --- diff --git a/test-resources/template-backups/test6-results/k8up-lagoon-backup-schedule.yaml b/test-resources/template-backups/test6-results/k8up-lagoon-backup-schedule.yaml index f5b6241a..f56499d0 100644 --- a/test-resources/template-backups/test6-results/k8up-lagoon-backup-schedule.yaml +++ b/test-resources/template-backups/test6-results/k8up-lagoon-backup-schedule.yaml @@ -30,7 +30,7 @@ spec: schedule: 5,20,35,50 5 * * 0 check: resources: {} - schedule: 5 5 * * 0 + schedule: 5 7 * * 1 prune: resources: {} retention: @@ -38,6 +38,6 @@ spec: keepHourly: 10 keepMonthly: 12 keepWeekly: 16 - schedule: 5 5 * * 0 + schedule: 5 2 * * 0 resourceRequirementsTemplate: {} status: {}