Skip to content

feat(backup): cron-based backup scheduling with friendly UI picker#466

Merged
javi11 merged 4 commits intomainfrom
feat/cron-backup-schedule
Apr 3, 2026
Merged

feat(backup): cron-based backup scheduling with friendly UI picker#466
javi11 merged 4 commits intomainfrom
feat/cron-backup-schedule

Conversation

@javi11
Copy link
Copy Markdown
Owner

@javi11 javi11 commented Apr 3, 2026

Summary

  • Replaces the confusing interval_hours + backup_time dual-field approach (where backup_time silently took priority with no indication) with a single schedule cron expression field, powered by robfig/cron/v3
  • Adds a friendly schedule picker UI (hourly / daily / weekly / custom) that generates the cron string behind the scenes
  • Raises keep_backups default from 1 → 10 and improves all backup-related labels and descriptions

Changes

Backend

  • Add github.com/robfig/cron/v3 dependency
  • MetadataBackupConfig: remove IntervalHours/BackupTime, add Schedule (standard cron expression, UTC)
  • Config validation: parse cron expression via cron.ParseStandard on load
  • backup_worker: replace manual time.After loop with cron.New(WithLocation(UTC)) runner — cleaner lifecycle, proper Stop() via cronRunner.Stop() with graceful drain
  • Remove GetMetadataBackupInterval accessor
  • Default: "0 3 * * *" (daily 3 AM UTC)

Frontend

  • MetadataBackupConfig type: schedule: string replaces interval_hours + backup_time
  • Schedule picker with four modes: Every hour, Daily (time input), Weekly (day + time), Custom (raw cron input)
  • parseCronString / buildCronString helpers for round-tripping picker state ↔ cron string
  • "Keep Last N Backups" replaces cryptic "Retention (Count)" label

Test plan

  • Go build passes: go build ./...
  • Go tests pass: go test github.com/javi11/altmount/internal/metadata
  • Frontend check passes: bun run check
  • Set schedule via UI (daily, weekly, custom) → verify saved cron string is correct
  • Enable backup in config → confirm worker logs show schedule=... on start
  • Invalid cron expression in config → confirm validation error is returned

🤖 Generated with Claude Code

javi11 and others added 4 commits April 3, 2026 17:00
…uling

Replace the confusing `interval_hours` + `backup_time` dual-field approach
(where backup_time silently took priority) with a single `schedule` cron
expression field using robfig/cron/v3.

Backend:
- Add robfig/cron/v3 dependency
- MetadataBackupConfig: remove IntervalHours/BackupTime, add Schedule (cron expr)
- Validate cron expression on config load via cron.ParseStandard
- backup_worker: replace manual time.After loop with cron.New runner
- Remove GetMetadataBackupInterval accessor (no longer needed)
- Default schedule: "0 3 * * *" (daily 3 AM UTC), keep_backups default raised to 10

Frontend:
- MetadataBackupConfig type: schedule string replaces interval_hours + backup_time
- New schedule picker UI: hourly / daily / weekly / custom (raw cron) modes
- parseCronString / buildCronString helpers for round-tripping friendly ↔ cron
- "Keep Last N Backups" label with clear helper text replaces "Retention (Count)"

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Add cronstrue to show a plain-English description of the active cron
expression below the schedule picker. Invalid custom expressions display
an inline error in red instead of silently failing.

Examples: "Runs: Every hour (UTC)", "Runs: At 03:00, only on Monday (UTC)"

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…le picker

Replace manual regex/string-split parseCronString with CronExpressionParser
from cron-parser, which properly handles edge cases like Sunday=7 normalization,
ranges, and invalid expressions via try/catch.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Move ScheduleType, ScheduleState, DAY_NAMES, parseCronString, and
buildCronString from MetadataConfigSection into frontend/src/utils/cronSchedule.ts
for reusability and separation of concerns.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@javi11 javi11 merged commit d2ec2f4 into main Apr 3, 2026
2 checks passed
@javi11 javi11 deleted the feat/cron-backup-schedule branch April 3, 2026 15:25
drondeseries referenced this pull request in drondeseries/altmount_old Apr 16, 2026
…466)

* feat(backup): replace dual interval/time fields with cron-based scheduling

Replace the confusing `interval_hours` + `backup_time` dual-field approach
(where backup_time silently took priority) with a single `schedule` cron
expression field using robfig/cron/v3.

Backend:
- Add robfig/cron/v3 dependency
- MetadataBackupConfig: remove IntervalHours/BackupTime, add Schedule (cron expr)
- Validate cron expression on config load via cron.ParseStandard
- backup_worker: replace manual time.After loop with cron.New runner
- Remove GetMetadataBackupInterval accessor (no longer needed)
- Default schedule: "0 3 * * *" (daily 3 AM UTC), keep_backups default raised to 10

Frontend:
- MetadataBackupConfig type: schedule string replaces interval_hours + backup_time
- New schedule picker UI: hourly / daily / weekly / custom (raw cron) modes
- parseCronString / buildCronString helpers for round-tripping friendly ↔ cron
- "Keep Last N Backups" label with clear helper text replaces "Retention (Count)"

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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