From 1d6957f45f0d6dd46854c6e40517fa4a22355c42 Mon Sep 17 00:00:00 2001 From: Ian Fijolek Date: Wed, 2 Aug 2023 14:58:26 -0700 Subject: [PATCH] Fix mysql restoration Password and database weren't passed to the mysql command --- tasks.go | 6 +++++- tasks_test.go | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/tasks.go b/tasks.go index 61fdbf9..e951fc9 100644 --- a/tasks.go +++ b/tasks.go @@ -165,7 +165,11 @@ func (t JobTaskMySQL) GetPostTask() ExecutableTask { } if t.Password != "" { - command = append(command, "--password", t.Password) + command = append(command, fmt.Sprintf("--password=%s", t.Password)) + } + + if t.Database != "" { + command = append(command, t.Database) } command = append(command, "<", t.DumpToPath) diff --git a/tasks_test.go b/tasks_test.go index c628c34..0706c39 100644 --- a/tasks_test.go +++ b/tasks_test.go @@ -163,7 +163,7 @@ func TestJobTaskSql(t *testing.T) { " --user user --password=pass --no-tablespaces db table1 table2", postBackup: "", preRestore: "", - postRestore: "mysql --host host --user user --password pass < ./simple.sql", + postRestore: "mysql --host host --user user --password=pass db < ./simple.sql", }, // Sqlite {