forked from xelabs/go-mydumper
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
142 additions
and
104 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
[mysql] | ||
# The host to connect to | ||
host = 127.0.0.1 | ||
# TCP/IP port to conect to | ||
port = 3306 | ||
# Username with privileges to run the dump | ||
user = root | ||
# User password | ||
password = pwd | ||
# Database to dump | ||
database = xx | ||
# Directory to dump files to | ||
outdir = ./dumper-sql |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
/* | ||
* go-mydumper | ||
* xelabs.org | ||
* | ||
* Copyright (c) XeLabs | ||
* GPL License | ||
* | ||
*/ | ||
|
||
package main | ||
|
||
import ( | ||
"common" | ||
"fmt" | ||
|
||
ini "github.com/dlintw/goconf" | ||
) | ||
|
||
func parseConfig(file string) (*common.Args, error) { | ||
args := &common.Args{} | ||
|
||
cfg, err := ini.ReadConfigFile(file) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
host, err := cfg.GetString("mysql", "host") | ||
if err != nil { | ||
return nil, err | ||
} | ||
port, err := cfg.GetInt("mysql", "port") | ||
if err != nil { | ||
return nil, err | ||
} | ||
user, err := cfg.GetString("mysql", "user") | ||
if err != nil { | ||
return nil, err | ||
} | ||
password, err := cfg.GetString("mysql", "password") | ||
if err != nil { | ||
return nil, err | ||
} | ||
database, err := cfg.GetString("mysql", "database") | ||
if err != nil { | ||
return nil, err | ||
} | ||
outdir, err := cfg.GetString("mysql", "outdir") | ||
if err != nil { | ||
return nil, err | ||
} | ||
table, _ := cfg.GetString("mysql", "table") | ||
sessionVars, _ := cfg.GetString("mysql", "vars") | ||
|
||
args.Address = fmt.Sprintf("%s:%d", host, port) | ||
args.User = user | ||
args.Password = password | ||
args.Database = database | ||
args.Table = table | ||
args.Outdir = outdir | ||
args.ChunksizeInMB = 128 | ||
args.Threads = 16 | ||
args.StmtSize = 1000000 | ||
args.IntervalMs = 10 * 1000 | ||
args.SessionVars = sessionVars | ||
return args, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/* | ||
* go-mydumper | ||
* xelabs.org | ||
* | ||
* Copyright (c) XeLabs | ||
* GPL License | ||
* | ||
*/ | ||
|
||
package main | ||
|
||
import ( | ||
"common" | ||
"flag" | ||
"fmt" | ||
"os" | ||
|
||
"github.com/xelabs/go-mysqlstack/xlog" | ||
) | ||
|
||
var ( | ||
flagConfig string | ||
|
||
log = xlog.NewStdLog(xlog.Level(xlog.INFO)) | ||
) | ||
|
||
func init() { | ||
flag.StringVar(&flagConfig, "c", "", "config file") | ||
} | ||
|
||
func usage() { | ||
fmt.Println("Usage: " + os.Args[0] + " -c conf/mydumper.ini.sample") | ||
flag.PrintDefaults() | ||
} | ||
|
||
func main() { | ||
flag.Usage = func() { usage() } | ||
flag.Parse() | ||
|
||
if flagConfig == "" { | ||
usage() | ||
os.Exit(0) | ||
} | ||
|
||
args, err := parseConfig(flagConfig) | ||
common.AssertNil(err) | ||
|
||
if _, err := os.Stat(args.Outdir); os.IsNotExist(err) { | ||
x := os.MkdirAll(args.Outdir, 0777) | ||
common.AssertNil(x) | ||
} | ||
|
||
common.Dumper(log, args) | ||
} |
File renamed without changes.
File renamed without changes.
This file was deleted.
Oops, something went wrong.