Skip to content

feat: complete database backup management API#8505

Closed
ripgtxgt wants to merge 1 commit intocoollabsio:nextfrom
ripgtxgt:feat/database-backup-api-next
Closed

feat: complete database backup management API#8505
ripgtxgt wants to merge 1 commit intocoollabsio:nextfrom
ripgtxgt:feat/database-backup-api-next

Conversation

@ripgtxgt
Copy link
Copy Markdown

Changes

Completes the database backup management API requested in #5672. The core backup endpoints already existed; this PR fills the gaps:

1. PATCH /databases/:uuid — new backup_* fields to configure backup inline (no need to know scheduled_backup_uuid first). Auto-creates backup config if none exists.

2. GET /databases — each backup_config now includes last_successful_backup ISO-8601 timestamp.

3. POST /databases/:uuid/backups — expose disable_local_backup field.

4. PATCH /databases/:uuid/backups/:uuid — fix frequency validation to accept custom cron expressions (not just enum aliases); expose disable_local_backup.

Issues

Category

  • New feature

AI Usage

  • AI is used in the process of creating this PR

Steps to Test

  1. PATCH /api/v1/databases/{uuid} with backup_frequency, backup_save_s3, backup_enabled fields
  2. Verify backup config is created/updated correctly
  3. GET /api/v1/databases and verify last_successful_backup field present in backup_configs
  4. POST /api/v1/databases/{uuid}/backups with disable_local_backup: true and verify it saves

Contributor Agreement

Important

  • I have read and understood the contributor guidelines. If I have failed to follow any guideline, I understand that this PR may be closed without review.
  • I have tested the changes thoroughly and am confident that they will work as expected without issues when the maintainer tests them

Changes
-------

### PATCH /databases/:uuid — backup configuration support
Adds optional backup_* fields so callers can configure (or auto-create)
a database's backup schedule through the existing resource endpoint,
without needing to know the scheduled_backup_uuid:

  backup_save_s3, backup_frequency, backup_s3_storage_uuid,
  backup_enabled, backup_disable_local_backup,
  backup_databases_to_backup, backup_dump_all,
  backup_retention_{amount,days,max_storage}_{locally,s3}

If no backup config exists for the database, one is automatically
created with sane defaults.  The backup_* prefix avoids any collision
with existing database fields.

### GET /databases — last_successful_backup timestamp
Each backup_config entry now includes a `last_successful_backup`
ISO-8601 timestamp (null when no successful run has occurred yet),
satisfying the issue requirement to surface backup health at a glance
without a second API call.

### POST /databases/:uuid/backups — expose disable_local_backup
Added `disable_local_backup` (boolean) to the create-backup endpoint so
callers can configure S3-only backups from the start.

### PATCH /databases/:uuid/backups/:uuid — fix frequency validation + disable_local_backup
- The frequency field was previously validated with a strict enum
  (every_minute|hourly|daily|weekly|monthly|yearly), preventing custom
  cron expressions.  Validation is now delegated to the same
  `validate_cron_expression()` helper used by the create endpoint.
- Added `disable_local_backup` to the allowed/validated fields.

All other backup endpoints (GET backups, DELETE backup, DELETE execution,
GET executions) were already implemented and are unchanged.

Closes coollabsio#5672
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 25, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants