From cc6934776b884e0762b913fef2c4cde628787a4c Mon Sep 17 00:00:00 2001 From: Matthew Morris Date: Thu, 9 Jul 2026 00:12:19 -0400 Subject: [PATCH 1/2] Enable daily backups by default on fresh deploys Sets a default backup cron (03:00 daily, keep 7) when unconfigured, so a new deploy isn't one volume wipe from data loss. Env-overridable via PRIMO_BACKUP_CRON; only set when empty so an admin-UI schedule isn't clobbered. --- migrations/1757326540_settings.go | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/migrations/1757326540_settings.go b/migrations/1757326540_settings.go index 380ccc41e..6f9189d99 100644 --- a/migrations/1757326540_settings.go +++ b/migrations/1757326540_settings.go @@ -17,6 +17,21 @@ func init() { } settings.Meta.AppName = "Primo CMS" + + // Enable automatic backups by default so a fresh deploy isn't one + // volume wipe away from total data loss. Stored on the pb_data + // volume (backups/ dir) — a floor, not off-site protection; wire up + // Backups.S3 for that. Env-overridable; only set when unconfigured + // so we never clobber a schedule set via the admin UI. + if settings.Backups.Cron == "" { + cron := os.Getenv("PRIMO_BACKUP_CRON") + if cron == "" { + cron = "0 3 * * *" // daily at 03:00 + } + settings.Backups.Cron = cron + settings.Backups.CronMaxKeep = 7 + } + app.Save(settings) superuserEmail := os.Getenv("PRIMO_SUPERUSER_EMAIL") From f3e15a7a18373d334f5061fd90d91931ee4eec46 Mon Sep 17 00:00:00 2001 From: Matthew Morris Date: Thu, 9 Jul 2026 00:52:56 -0400 Subject: [PATCH 2/2] Propagate settings save error in default-backup migration Return the app.Save(settings) error so a failed write aborts the migration instead of leaving a fresh install without the backup schedule. --- migrations/1757326540_settings.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/migrations/1757326540_settings.go b/migrations/1757326540_settings.go index 6f9189d99..71f535e62 100644 --- a/migrations/1757326540_settings.go +++ b/migrations/1757326540_settings.go @@ -32,7 +32,9 @@ func init() { settings.Backups.CronMaxKeep = 7 } - app.Save(settings) + if err := app.Save(settings); err != nil { + return err + } superuserEmail := os.Getenv("PRIMO_SUPERUSER_EMAIL") superuserPassword := os.Getenv("PRIMO_SUPERUSER_PASSWORD")