-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathargs.go
More file actions
56 lines (51 loc) · 1.74 KB
/
Copy pathargs.go
File metadata and controls
56 lines (51 loc) · 1.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
package mysqlcommon
import (
"strconv"
"github.com/nixrajput/siphon/internal/driver"
)
// BuildDumpArgs assembles the mysqldump argument vector for a backup. The
// binary name itself is supplied by the caller (mysqldump vs mariadb-dump).
func BuildDumpArgs(p driver.Profile, opt driver.BackupOpts) []string {
args := []string{
"-h", p.Host,
"-P", strconv.Itoa(p.Port),
"-u", p.User,
"--single-transaction",
"--routines",
"--triggers",
"--events",
"--no-tablespaces",
"--skip-comments",
p.Database,
}
if opt.SchemaOnly {
args = append(args, "--no-data")
}
if opt.DataOnly {
args = append(args, "--no-create-info")
}
args = append(args, opt.IncludeTables...)
for _, t := range opt.ExcludeTables {
args = append(args, "--ignore-table="+p.Database+"."+t)
}
return args
}
// BuildRestoreArgs assembles the mysql client argument vector for a restore.
// The dump file is authoritative for shape; the restore client just pipes it
// in. Clean is a no-op here because mysqldump output already emits
// DROP TABLE IF EXISTS / CREATE TABLE, making the restore idempotent.
func BuildRestoreArgs(p driver.Profile, _ driver.RestoreOpts) []string {
return []string{
"-h", p.Host,
"-P", strconv.Itoa(p.Port),
"-u", p.User,
"--default-character-set=utf8mb4",
p.Database,
}
}
// NOTE: Profile.SSLMode is honored by the connect DSN (see dsn.go) but is NOT
// yet propagated to the dump/restore CLI tools. The flag differs across forks —
// MySQL's mysqldump uses --ssl-mode=<DISABLED|REQUIRED|VERIFY_CA|VERIFY_IDENTITY>
// while MariaDB's mariadb-dump uses --ssl / --skip-ssl — so it needs per-fork
// handling (and the dump tools' stderr surfaced so a rejected flag isn't opaque).
// Tracked as a follow-up; see the PR #4 discussion.