Skip to content

MySQL db support - #5

Merged
coorasse merged 16 commits into
mainfrom
feature/mysql-db-backups
Nov 4, 2026
Merged

coorasse merged 16 commits into
mainfrom
feature/mysql-db-backups

Conversation

@Stiwyy

@Stiwyy Stiwyy commented Sep 4, 2026

Copy link
Copy Markdown
Member

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   

@Stiwyy
Stiwyy requested a review from cb341 September 4, 2026 16:55
@Stiwyy Stiwyy self-assigned this Sep 4, 2026
@cb341
cb341 force-pushed the feature/mysql-db-backups branch from 7c341d2 to 9082fc0 Compare September 7, 2026 06:37
@cb341

cb341 commented Sep 7, 2026

Copy link
Copy Markdown

#4

@cb341
cb341 requested review from lukasbischof and removed request for cb341 September 11, 2026 07:18

@lukasbischof lukasbischof left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

  1. 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)
  2. 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
  3. 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
  4. 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:

  1. Don't use "MS" abbreviation. It's very misleading to Microsoft / MSSQL. Prefer either MySQL or "my"
  2. 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.

Comment thread lib/deploio/commands/mysql.rb Resolved
Comment thread lib/deploio/commands/mysql.rb Resolved
@Stiwyy
Stiwyy requested a review from lukasbischof October 13, 2026 13:56

@lukasbischof lukasbischof left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Image

that holds two tables:
Image

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 seconds

Downloading fails, however:
Image
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 🎉

Comment thread lib/deploio/postgres_backup_service.rb Resolved
Comment thread lib/deploio/commands/mysql_backups.rb Resolved
Comment thread lib/deploio/commands/mysql_backups.rb Resolved
Comment thread lib/deploio/mysql_backup_service.rb Resolved
Comment thread lib/deploio/mysql_backup_service.rb Resolved
@Stiwyy
Stiwyy requested a review from lukasbischof October 14, 2026 14:44

@lukasbischof lukasbischof left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice, thanks for your implementation. Just some minor things but then it looks good to me

Comment thread lib/deploio/postgres_backup_service.rb Outdated
Comment on lines +50 to +51
"Databases: #{databases.join(", ")}\n" \
"Please specify the database name using the --db_name option."

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unnecessary change

Suggested 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."

Comment thread lib/deploio/postgres_backup_service.rb Outdated
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."

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unnecessary change

Suggested change
"Use 'deploio pg backups download #{@name}' to fetch it."
"Use 'deploio pg backups download #{@name}' to fetch it."

Comment on lines +31 to +32
"on their configured schedule and cannot be captured manually.\n" \
"Use 'deploio pg backups list #{@name}' to see the available backups."

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also unnecessary changes

Suggested change
"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)."

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And here

Suggested change
"Check that backups are enabled for this database (spec.forProvider.backupSchedule)."
"Check that backups are enabled for this database (spec.forProvider.backupSchedule)."

@coorasse
coorasse merged commit 73893c0 into main Nov 4, 2026
4 checks passed
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.

4 participants