dokploy icon indicating copy to clipboard operation
dokploy copied to clipboard

MySQL backups omit stored procedures, functions and events

Open lmachineone opened this issue 1 month ago • 1 comments

Problem

MySQL database backups omit stored procedures, functions and scheduled event definitions. A backup can complete successfully and restore its tables while leaving application routines unavailable.

On current canary (5be17d3dd01d9489521cde2eca7d997b14c54653), getMysqlBackupCommand in packages/server/src/utils/backups/utils.ts invokes mysqldump without --routines or --events. Both native MySQL and Compose MySQL backups use this builder.

Reproduction

  1. Create a MySQL database with a table, a stored procedure, a deterministic function, and a disabled event.
  2. Create a database backup through Dokploy.
  3. Restore the archive into an empty database.
  4. Compare the source and restored information_schema.ROUTINES and information_schema.EVENTS entries.

Expected: the selected database's stored object definitions are included alongside its tables, views and triggers.

Current command behavior: routines and events are not selected for the dump. MySQL documents that they require the explicit --routines and --events options.

Proposed fix and validation

Add these options to the shared MySQL backup builder, retaining the existing selected-database scope, root authentication, shell quoting, UTF-8 encoding, transaction flags, gzip and error handling. Validate a synthetic MySQL 8.4 backup/restore round trip through the actual command builders and restore filter, with event scheduling disabled. This does not include MariaDB, server users/grants or backup configuration changes.

Local validation and compatibility finding

Using official MySQL 8.4.11 containers, the current command restored tables, UTF-8 rows, a view and a trigger, but omitted both routines and the disabled event. Adding the two options preserved and restored the procedure, deterministic function and disabled event through the native and Compose command paths. The restored procedure and function returned the expected values. A missing-database dump failure propagated and removed its partial archive.

There is a client compatibility caveat: with an apostrophe in the database identifier, MySQL 8.4.11 mysqldump --routines fails with error 1049, including when that database contains no routines. The same dump succeeds without --routines. This matches verified MySQL bug #84214; shell argument transport itself was preserved. The contribution will stay draft with this limitation explicit for review.

lmachineone avatar Oct 07 '26 18:10 lmachineone

DOK-841

linear-code[bot] avatar Oct 07 '26 18:10 linear-code[bot]