Skip to content

Enable daily backups by default on fresh deploys#1202

Merged
elemdos merged 2 commits into
mainfrom
chore/default-backup-cron
Jul 9, 2026
Merged

Enable daily backups by default on fresh deploys#1202
elemdos merged 2 commits into
mainfrom
chore/default-backup-cron

Conversation

@elemdos

@elemdos elemdos commented Jul 9, 2026

Copy link
Copy Markdown
Collaborator

What

Sets a default backup schedule when none is configured, so a fresh deploy isn't one volume wipe away from total data loss.

  • Cron 0 3 * * * (daily at 03:00), CronMaxKeep = 7, applied in the settings migration.
  • Overridable via PRIMO_BACKUP_CRON.
  • Only set when settings.Backups.Cron is empty, so a schedule configured through the admin UI is never clobbered.

Caveat

Backups land on the pb_data volume (backups/ dir) — a floor, not off-site protection. For durable backups, configure Backups.S3.

Summary by CodeRabbit

  • New Features
    • Automatic backups are now enabled by default during setup.
    • A default backup schedule is applied when none is configured, with a sensible retention limit.
  • Bug Fixes
    • Existing setup behavior remains unchanged aside from the new backup defaults, helping ensure fresh installs start with backups configured.

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.
@coderabbitai

coderabbitai Bot commented Jul 9, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 0ee88eb6-0fb6-454c-a496-6d0d11a7ea1d

📥 Commits

Reviewing files that changed from the base of the PR and between cc69347 and f3e15a7.

📒 Files selected for processing (1)
  • migrations/1757326540_settings.go
🚧 Files skipped from review as they are similar to previous changes (1)
  • migrations/1757326540_settings.go

📝 Walkthrough

Walkthrough

The settings migration now sets default backup scheduling when settings.Backups.Cron is empty, using PRIMO_BACKUP_CRON or 0 3 * * *, and sets settings.Backups.CronMaxKeep to 7 before saving.

Changes

Backup default scheduling

Layer / File(s) Summary
Default cron/backup settings in migration
migrations/1757326540_settings.go
Sets a default backup cron schedule from PRIMO_BACKUP_CRON or a daily fallback, and a default retention count of 7, when no cron schedule is already configured.

Estimated code review effort: 1 (Trivial) | ~3 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the main change: enabling default daily backups on fresh deploys.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch chore/default-backup-cron

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@migrations/1757326540_settings.go`:
- Around line 26-35: The migration in the settings bootstrap path updates
`settings.Backups.Cron` and `settings.Backups.CronMaxKeep` but ignores the
result of `app.Save(settings)`, so a failed write can be silently skipped.
Update this migration to check and return the error from `app.Save(settings)`
instead of discarding it, using the existing migration logic around
`settings.Backups.Cron` and `settings.Backups.CronMaxKeep` to keep the save
atomic and stop the migration on failure.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 0c94fc4f-298f-4920-8602-828e9926e3be

📥 Commits

Reviewing files that changed from the base of the PR and between 3755150 and cc69347.

📒 Files selected for processing (1)
  • migrations/1757326540_settings.go

Comment thread migrations/1757326540_settings.go Outdated
Return the app.Save(settings) error so a failed write aborts the migration
instead of leaving a fresh install without the backup schedule.
@elemdos elemdos merged commit 8278244 into main Jul 9, 2026
6 checks passed
@elemdos elemdos deleted the chore/default-backup-cron branch July 9, 2026 05:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant