Add more mysql options
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
Default to --all-databases if none specified and add --no-tablespaces option
This commit is contained in:
parent
ced262d52c
commit
12b1cfbb06
23
tasks.go
23
tasks.go
@ -69,14 +69,15 @@ 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"`
|
||||
Username string `hcl:"username,optional"`
|
||||
Password string `hcl:"password,optional"`
|
||||
Tables []string `hcl:"tables,optional"`
|
||||
DumpToPath string `hcl:"dump_to"`
|
||||
Port int `hcl:"port,optional"`
|
||||
Name string `hcl:"name,label"`
|
||||
Hostname string `hcl:"hostname,optional"`
|
||||
Database string `hcl:"database,optional"`
|
||||
Username string `hcl:"username,optional"`
|
||||
Password string `hcl:"password,optional"`
|
||||
Tables []string `hcl:"tables,optional"`
|
||||
NoTablespaces bool `hcl:"no_tablespaces,optional"`
|
||||
DumpToPath string `hcl:"dump_to"`
|
||||
}
|
||||
|
||||
func (t JobTaskMySQL) Paths() []string {
|
||||
@ -126,8 +127,14 @@ func (t JobTaskMySQL) GetPreTask() ExecutableTask {
|
||||
command = append(command, "--password", t.Password)
|
||||
}
|
||||
|
||||
if t.NoTablespaces {
|
||||
command = append(command, "--no-tablespaces")
|
||||
}
|
||||
|
||||
if t.Database != "" {
|
||||
command = append(command, t.Database)
|
||||
} else {
|
||||
command = append(command, "--all-databases")
|
||||
}
|
||||
|
||||
command = append(command, t.Tables...)
|
||||
|
@ -126,7 +126,7 @@ func TestJobTaskSql(t *testing.T) {
|
||||
DumpToPath: "./simple.sql",
|
||||
},
|
||||
validationErr: nil,
|
||||
preBackup: "mysqldump --result-file ./simple.sql",
|
||||
preBackup: "mysqldump --result-file ./simple.sql --all-databases",
|
||||
postBackup: "",
|
||||
preRestore: "",
|
||||
postRestore: "mysql < ./simple.sql",
|
||||
@ -148,18 +148,19 @@ func TestJobTaskSql(t *testing.T) {
|
||||
{
|
||||
name: "mysql all options",
|
||||
task: main.JobTaskMySQL{
|
||||
Name: "simple",
|
||||
Hostname: "host",
|
||||
Port: 3306,
|
||||
Username: "user",
|
||||
Password: "pass",
|
||||
Database: "db",
|
||||
Tables: []string{"table1", "table2"},
|
||||
DumpToPath: "./simple.sql",
|
||||
Name: "simple",
|
||||
Hostname: "host",
|
||||
Port: 3306,
|
||||
Username: "user",
|
||||
Password: "pass",
|
||||
Database: "db",
|
||||
NoTablespaces: true,
|
||||
Tables: []string{"table1", "table2"},
|
||||
DumpToPath: "./simple.sql",
|
||||
},
|
||||
validationErr: nil,
|
||||
preBackup: "mysqldump --result-file ./simple.sql --host host --port 3306" +
|
||||
" --user user --password pass db table1 table2",
|
||||
" --user user --password pass --no-tablespaces db table1 table2",
|
||||
postBackup: "",
|
||||
preRestore: "",
|
||||
postRestore: "mysql --host host --user user --password pass < ./simple.sql",
|
||||
|
Loading…
Reference in New Issue
Block a user