Skip to content

feat: @ottabase/backups — timestamped filenames, day-based retention, admin settings UI#132

Draft
Copilot wants to merge 8 commits intomainfrom
copilot/add-admin-ui-for-db-backups
Draft

feat: @ottabase/backups — timestamped filenames, day-based retention, admin settings UI#132
Copilot wants to merge 8 commits intomainfrom
copilot/add-admin-ui-for-db-backups

Conversation

Copy link
Copy Markdown

Copilot AI commented Feb 28, 2026

Implements @ottabase/backups with D1→R2 automated backup service and admin UI, then fixes several issues in the initial implementation: wrong filename format, missing day-based retention, no admin-configurable settings, and a route collision.

Core package (packages/backups/)

  • Timestamped filenames: yyyy-mm-dd-hhmmss_appName.sql instead of {uuid}.sql
  • Day-based retention: retentionDays config (rolling window) alongside existing count-based maxRetained
  • appName config: Sourced from ottabase.config.ts, sanitized for filesystem safety
  • Backward compat: deleteBackup/downloadBackup resolve keys for both legacy UUID and new timestamped formats via resolveBackupKey()
const service = createBackupService(env.OBCF_D1, env.OBCF_R2, {
  appName: 'my-app',     // → 2024-06-15-023000_my-app.sql
  retentionDays: 30,     // delete backups older than 30 days
  maxRetained: 30,       // also cap at 30 total
});

Admin API (worker/routes/admin-backups.ts)

  • GET/PUT /api/admin/backups/settings — configure schedule (cron expression) and retention days
  • Settings persisted in ScheduledTask model payload as { retentionDays }, read back during backup creation for enforcement consistency
  • Route ordering fix: /settings matched before /:id regex catch-all

Admin UI (AdminBackupsPage.tsx)

  • Settings panel: schedule presets dropdown + retention days input, creates/updates backup:database cron task
  • Pending setup banner: shows actionable items when D1/R2/cron not configured, with inline "Configure →" link
  • Download uses original timestamped filename

Tests

42 tests (8 new): generateBackupFilename, day-based retention pruning, new-format delete/download, backward compat with legacy keys.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 4 commits February 28, 2026 21:30
Co-authored-by: thinkdj <688055+thinkdj@users.noreply.github.com>
Co-authored-by: thinkdj <688055+thinkdj@users.noreply.github.com>
…type safety

Co-authored-by: thinkdj <688055+thinkdj@users.noreply.github.com>
… CVE

Co-authored-by: thinkdj <688055+thinkdj@users.noreply.github.com>
Copilot AI changed the title [WIP] Implement automated D1 to R2 backups with admin UI feat: @ottabase/backups — Automated D1→R2 backup package with admin UI Feb 28, 2026
Copilot AI and others added 3 commits February 28, 2026 22:50
…ottabase/backups

Co-authored-by: thinkdj <688055+thinkdj@users.noreply.github.com>
…ision fix

Co-authored-by: thinkdj <688055+thinkdj@users.noreply.github.com>
Co-authored-by: thinkdj <688055+thinkdj@users.noreply.github.com>
Copilot AI changed the title feat: @ottabase/backups — Automated D1→R2 backup package with admin UI feat: @ottabase/backups — timestamped filenames, day-based retention, admin settings UI Feb 28, 2026
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.

2 participants