Repository navigation
MySQL db support - #5
Conversation
7c341d2 to
9082fc0
Compare
lukasbischof
left a comment
There was a problem hiding this comment.
Thanks for your contribution!
The MySQL command definitely is overdue. But I think, the added abstraction of abstract base classes in this case is not worth the overhead.
- There are only two descendants, violating the rule of three (which is a rule of thumb so there are cases in which it is justified. But not really here)
- Abstract classes anyway are not really a thing in Ruby. You can enforce it with type checkers, but plain Ruby doesn't know abstract classes, so you have to simulate it
- It is a collection of bash commands. I like the idea that I can read the source code and have the step by step instructions there. This already is only partially the case, but the abstraction makes it even worse
- In a "real" project, this would quickly accumulate to tech debt. To be fair, the impact in the Deploio CLI is limited. But doing things in a clean way is a good habit anyway :)
So can we change the two things:
- Don't use "MS" abbreviation. It's very misleading to Microsoft / MSSQL. Prefer either MySQL or "my"
- Inline the commands for MySQL and Postgres. This will lead to duplication, but I think it's fine, especially as we only have the two types anyway.
If you do want to share logic where useful, you can still extract it to a helper (for example, the finding of a bucket could be a helper method)
General design thought but not scope of this PR: Maybe it would be a good idea to merge the two together and have a single db command. Currently, the PG command already does something similar: It lists economy and dedicated instances. The upside would be that I don't have to know which projects uses which databases and could see it on first glance when I list all dbs.
Furthermore, we could also reduce code duplication. On the con side, the commands would take longer as we'd have to list databases four times: pg eco and dedicated as well as mysql eco and dedicated.
lukasbischof
left a comment
There was a problem hiding this comment.
Seems like the backups download for the dedicated MySQL databases does not work yet. I've created a dedicated database server to test the command with the following content:
A MySQL database called testing

Capturing works correctly, calling the backup script:
$ deploio mysql backups capture renuotest-mysql-dedicated-test
> ssh dbadmin@mysql-dedicated-test.21ddead.mysql.nineapis.ch sudo nine-mysql-backup
2026-10-14T15:34:49+02:00 Dumped and compressed database 'testing' in 0 secondsDownloading fails, however:

The rsync commands fails but the CLI says it has been stored successfully.
The directory structure looks like this:
dbadmin@managedvirtualmachine-4c9de4d:~/backup/mysql/latest/customer/testing$ ls -lah
total 16K
drwxr-x--- 2 root adm 4.0K Oct 14 15:34 .
drwxr-x--- 3 root adm 4.0K Oct 14 15:34 ..
-rw-r----- 1 root adm 742 Oct 14 15:34 heyllo.zst
-rw-r----- 1 root adm 783 Oct 14 15:34 my_tabby.zst
Besides the backups, the command seems to work fine tho 🎉
lukasbischof
left a comment
There was a problem hiding this comment.
nice, thanks for your implementation. Just some minor things but then it looks good to me
| "Databases: #{databases.join(", ")}\n" \ | ||
| "Please specify the database name using the --db_name option." |
There was a problem hiding this comment.
Unnecessary change
| "Databases: #{databases.join(", ")}\n" \ | |
| "Please specify the database name using the --db_name option." | |
| "Databases: #{databases.join(", ")}\n" \ | |
| "Please specify the database name using the --db_name option." |
| raise Deploio::UnsupportedBackupOperationError, | ||
| "Listing backups is not yet supported for dedicated PostgreSQL instances; Feel free to implement it!\n" \ | ||
| "Use 'deploio pg backups download #{@name}' to fetch it." | ||
| "Use 'deploio pg backups download #{@name}' to fetch it." |
There was a problem hiding this comment.
Unnecessary change
| "Use 'deploio pg backups download #{@name}' to fetch it." | |
| "Use 'deploio pg backups download #{@name}' to fetch it." |
| "on their configured schedule and cannot be captured manually.\n" \ | ||
| "Use 'deploio pg backups list #{@name}' to see the available backups." |
There was a problem hiding this comment.
Also unnecessary changes
| "on their configured schedule and cannot be captured manually.\n" \ | |
| "Use 'deploio pg backups list #{@name}' to see the available backups." | |
| "on their configured schedule and cannot be captured manually.\n" \ | |
| "Use 'deploio pg backups list #{@name}' to see the available backups." |
| raise Deploio::Error, | ||
| "No backup bucket found for '#{@db_ref.full_name}'. " \ | ||
| "Check that backups are enabled for this database (spec.forProvider.backupSchedule)." | ||
| "Check that backups are enabled for this database (spec.forProvider.backupSchedule)." |
There was a problem hiding this comment.
And here
| "Check that backups are enabled for this database (spec.forProvider.backupSchedule)." | |
| "Check that backups are enabled for this database (spec.forProvider.backupSchedule)." |

TICKET-26480
Move implementation of existing command to backup postgres dbs to a generic parent class. Add support for MySQL as well.
Command to download MySQL db backup:
ruby -Ilib ./bin/deploio ms backups download renuo-swissict-develop --output ~/Downloads/test.sql.zst