Add port specification to mysqldump
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
2b8b450861
commit
7935aaff96
5
tasks.go
5
tasks.go
@ -69,6 +69,7 @@ func (t *JobTaskScript) SetName(name string) {
|
||||
|
||||
// JobTaskMySQL is a sqlite backup task that performs required pre and post tasks.
|
||||
type JobTaskMySQL struct {
|
||||
Port int `hcl:"port,optional"`
|
||||
Name string `hcl:"name,label"`
|
||||
Hostname string `hcl:"hostname,optional"`
|
||||
Database string `hcl:"database,optional"`
|
||||
@ -113,6 +114,10 @@ func (t JobTaskMySQL) GetPreTask() ExecutableTask {
|
||||
command = append(command, "--host", t.Hostname)
|
||||
}
|
||||
|
||||
if t.Port != 0 {
|
||||
command = append(command, "--port", fmt.Sprintf("%d", t.Port))
|
||||
}
|
||||
|
||||
if t.Username != "" {
|
||||
command = append(command, "--user", t.Username)
|
||||
}
|
||||
|
@ -15,6 +15,7 @@ func NewBufferedLogger(prefix string) (*bytes.Buffer, *log.Logger) {
|
||||
|
||||
return &outputBuffer, logger
|
||||
}
|
||||
|
||||
func TestJobTaskScript(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
@ -149,6 +150,7 @@ func TestJobTaskSql(t *testing.T) {
|
||||
task: main.JobTaskMySQL{
|
||||
Name: "simple",
|
||||
Hostname: "host",
|
||||
Port: 3306,
|
||||
Username: "user",
|
||||
Password: "pass",
|
||||
Database: "db",
|
||||
@ -156,10 +158,11 @@ func TestJobTaskSql(t *testing.T) {
|
||||
DumpToPath: "./simple.sql",
|
||||
},
|
||||
validationErr: nil,
|
||||
preBackup: "mysqldump --result-file ./simple.sql --host host --user user --password pass db table1 table2",
|
||||
postBackup: "",
|
||||
preRestore: "",
|
||||
postRestore: "mysql --host host --user user --password pass < ./simple.sql",
|
||||
preBackup: "mysqldump --result-file ./simple.sql --host host --port 3306" +
|
||||
" --user user --password pass db table1 table2",
|
||||
postBackup: "",
|
||||
preRestore: "",
|
||||
postRestore: "mysql --host host --user user --password pass < ./simple.sql",
|
||||
},
|
||||
// Sqlite
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user