Skip to content

Commit

Permalink
Allow for backups with the mysqlsh engine
Browse files Browse the repository at this point in the history
Signed-off-by: Florent Poinsard <[email protected]>
  • Loading branch information
frouioui committed Aug 29, 2024
1 parent 4d4318c commit 39d0d7f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
19 changes: 13 additions & 6 deletions pkg/operator/vttablet/backup.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import (
"planetscale.dev/vitess-operator/pkg/operator/vitessbackup"
)

func xtrabackupFlags(spec *Spec, backupThreads, restoreThreads int) vitess.Flags {
func xtrabackupFlags(backupThreads, restoreThreads int) vitess.Flags {
flags := vitess.Flags{
"xtrabackup_user": xtrabackupUser,
"xtrabackup_stream_mode": xtrabackupStreamMode,
Expand All @@ -39,6 +39,15 @@ func xtrabackupFlags(spec *Spec, backupThreads, restoreThreads int) vitess.Flags
return flags
}

func mysqlshellFlags(backupLocation string) vitess.Flags {
flags := vitess.Flags{
"mysql-shell-backup-location": backupLocation,
"mysql-shell-flags": mysqlshellExtraFlags,
}

return flags
}

func init() {
vttabletFlags.Add(func(s lazy.Spec) vitess.Flags {
spec := s.(*Spec)
Expand Down Expand Up @@ -68,12 +77,10 @@ func init() {
if restoreThreads < 1 {
restoreThreads = 1
}
flags.Merge(xtrabackupFlags(spec, backupThreads, restoreThreads))
flags.Merge(xtrabackupFlags(backupThreads, restoreThreads))
case planetscalev2.VitessBackupEngineMySQLShell:
svm := vitessbackup.StorageVolumeMounts(spec.BackupLocation)
flags.Merge(vitess.Flags{
"mysql-shell-backup-location": svm[0].MountPath,
})
flags.Merge(mysqlshellFlags(svm[0].MountPath))
}
clusterName := spec.Labels[planetscalev2.ClusterLabel]
storageLocationFlags := vitessbackup.StorageFlags(spec.BackupLocation, clusterName)
Expand All @@ -99,7 +106,7 @@ func init() {
if threads < 1 {
threads = 1
}
flags.Merge(xtrabackupFlags(spec, threads, threads))
flags.Merge(xtrabackupFlags(threads, threads))
}
clusterName := spec.Labels[planetscalev2.ClusterLabel]
storageLocationFlags := vitessbackup.StorageFlags(spec.BackupLocation, clusterName)
Expand Down
3 changes: 3 additions & 0 deletions pkg/operator/vttablet/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,9 @@ const (
xtrabackupStripeCount = 8
xtrabackupUser = "vt_dba"

mysqlshellUser = "vt_dba"
mysqlshellExtraFlags = "--defaults-file=/dev/null --no-password --js -u " + mysqlshellUser + " -S " + mysqlSocketPath

// mysqlctlWaitTime is how long mysqlctld will wait for mysqld to start up
// before assuming it's stuck and trying to restart it. We set this fairly
// high because it can take a while to do crash recovery and it's rarely
Expand Down

0 comments on commit 39d0d7f

Please sign in to comment.