Skip to content

feat: allow MongoDB backup of all databases when database name is empty#4187

Open
krisvanmelis wants to merge 2 commits intoDokploy:canaryfrom
krisvanmelis:feat/mongodb-backup-all-databases
Open

feat: allow MongoDB backup of all databases when database name is empty#4187
krisvanmelis wants to merge 2 commits intoDokploy:canaryfrom
krisvanmelis:feat/mongodb-backup-all-databases

Conversation

@krisvanmelis
Copy link
Copy Markdown

@krisvanmelis krisvanmelis commented Apr 9, 2026

Summary

Closes #4186

  • When the database field is left empty for MongoDB backups, mongodump runs without the -d flag, dumping all databases in the instance
  • Other database types (Postgres, MySQL, MariaDB, libsql) still require a database name
  • Added UI hint for MongoDB: "Leave empty to back up all databases"

Changes

  • packages/server/src/utils/backups/utils.ts — Conditionally include -d flag in getMongoBackupCommand
  • packages/server/src/db/schema/backups.ts — Relaxed database field validation from min(1) to allow empty string
  • apps/dokploy/components/dashboard/database/backups/handle-backup.tsx — Added superRefine to require non-empty database for non-mongo types; added FormDescription hint for MongoDB

Test plan

  • Create a MongoDB backup with an empty database name → should dump all databases
  • Create a MongoDB backup with a specific database name → should dump only that database (existing behavior)
  • Create a Postgres/MySQL/MariaDB backup with empty database → should show validation error
  • Verify existing backups continue to work without changes

🤖 Generated with Claude Code

Greptile Summary

This PR adds support for MongoDB "dump all databases" mode by omitting the -d flag when the database field is empty, with corresponding frontend validation to require a database name only for non-MongoDB types. The frontend changes are clean and correct, but the server-side createSchema in backups.ts was relaxed globally (all types) without adding a compensating type-conditional refinement — meaning direct API calls can create broken backup configs for Postgres/MySQL/MariaDB/LibSQL with an empty database name that will silently fail at runtime.

Confidence Score: 4/5

Safe to merge after adding server-side databaseType-conditional validation to the backup schema.

There is one P1 defect: the server-side schema allows an empty database for all database types without enforcing the same databaseType-conditional rule as the frontend. A direct API call can persist a broken backup config that silently fails at execution time. All other changes (the mongodump flag logic, the UI hint, and the frontend superRefine) are correct.

packages/server/src/db/schema/backups.ts — createSchema needs a superRefine or per-schema refinement to reject empty database for non-mongo types.

Reviews (1): Last reviewed commit: "feat: allow MongoDB backup of all databa..." | Re-trigger Greptile

Greptile also left 2 inline comments on this PR.

(2/5) Greptile learns from your feedback when you react with thumbs up/down!

When the database field is left empty for MongoDB backups, mongodump
runs without the -d flag, which dumps all databases in the instance.
This is useful when users want a full backup without creating separate
backup entries for each database.

- Modified getMongoBackupCommand to conditionally include -d flag
- Relaxed database validation to allow empty string for MongoDB only
- Added UI hint for MongoDB: "Leave empty to back up all databases"

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@dosubot dosubot bot added size:S This PR changes 10-29 lines, ignoring generated files. enhancement New feature or request labels Apr 9, 2026
Comment thread packages/server/src/db/schema/backups.ts
Comment thread packages/server/src/utils/backups/utils.ts Outdated
…ommand

- Add superRefine to createSchema rejecting empty database for non-mongo types
- Fix double space in mongodump command when database is empty

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@krisvanmelis
Copy link
Copy Markdown
Author

Fixed both issues flagged by Greptile:

P1 — Server-side databaseType-conditional validation: Added .superRefine() to the server-side createSchema in packages/server/src/db/schema/backups.ts that rejects an empty database for non-mongo database types. This mirrors the frontend validation so direct API calls can no longer persist broken backup configs.

P2 — Double space in mongodump command: Moved the trailing space into dbFlag in packages/server/src/utils/backups/utils.ts so there's no double space in the generated command when database is empty.

@dosubot dosubot bot added size:M This PR changes 30-99 lines, ignoring generated files. and removed size:S This PR changes 10-29 lines, ignoring generated files. labels Apr 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request size:M This PR changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: Allow MongoDB backup of all databases (omit database name)

1 participant