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.
|
// JobTaskMySQL is a sqlite backup task that performs required pre and post tasks.
|
||||||
type JobTaskMySQL struct {
|
type JobTaskMySQL struct {
|
||||||
|
Port int `hcl:"port,optional"`
|
||||||
Name string `hcl:"name,label"`
|
Name string `hcl:"name,label"`
|
||||||
Hostname string `hcl:"hostname,optional"`
|
Hostname string `hcl:"hostname,optional"`
|
||||||
Database string `hcl:"database,optional"`
|
Database string `hcl:"database,optional"`
|
||||||
@ -113,6 +114,10 @@ func (t JobTaskMySQL) GetPreTask() ExecutableTask {
|
|||||||
command = append(command, "--host", t.Hostname)
|
command = append(command, "--host", t.Hostname)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if t.Port != 0 {
|
||||||
|
command = append(command, "--port", fmt.Sprintf("%d", t.Port))
|
||||||
|
}
|
||||||
|
|
||||||
if t.Username != "" {
|
if t.Username != "" {
|
||||||
command = append(command, "--user", t.Username)
|
command = append(command, "--user", t.Username)
|
||||||
}
|
}
|
||||||
|
@ -15,6 +15,7 @@ func NewBufferedLogger(prefix string) (*bytes.Buffer, *log.Logger) {
|
|||||||
|
|
||||||
return &outputBuffer, logger
|
return &outputBuffer, logger
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestJobTaskScript(t *testing.T) {
|
func TestJobTaskScript(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
|
|
||||||
@ -149,6 +150,7 @@ func TestJobTaskSql(t *testing.T) {
|
|||||||
task: main.JobTaskMySQL{
|
task: main.JobTaskMySQL{
|
||||||
Name: "simple",
|
Name: "simple",
|
||||||
Hostname: "host",
|
Hostname: "host",
|
||||||
|
Port: 3306,
|
||||||
Username: "user",
|
Username: "user",
|
||||||
Password: "pass",
|
Password: "pass",
|
||||||
Database: "db",
|
Database: "db",
|
||||||
@ -156,7 +158,8 @@ func TestJobTaskSql(t *testing.T) {
|
|||||||
DumpToPath: "./simple.sql",
|
DumpToPath: "./simple.sql",
|
||||||
},
|
},
|
||||||
validationErr: nil,
|
validationErr: nil,
|
||||||
preBackup: "mysqldump --result-file ./simple.sql --host host --user user --password pass db table1 table2",
|
preBackup: "mysqldump --result-file ./simple.sql --host host --port 3306" +
|
||||||
|
" --user user --password pass db table1 table2",
|
||||||
postBackup: "",
|
postBackup: "",
|
||||||
preRestore: "",
|
preRestore: "",
|
||||||
postRestore: "mysql --host host --user user --password pass < ./simple.sql",
|
postRestore: "mysql --host host --user user --password pass < ./simple.sql",
|
||||||
|
Loading…
Reference in New Issue
Block a user