From 664a20fde45ae90eef15d51ac7ba090d17cd7796 Mon Sep 17 00:00:00 2001 From: zhangpanfeng Date: Thu, 30 Nov 2023 15:38:37 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E5=AF=86=E7=A0=81?= =?UTF-8?q?=E4=BC=A0=E5=80=BC=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.go | 4 +--- pkg/config/config.go | 2 ++ 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/main.go b/main.go index 3e1fff5..32a79ff 100644 --- a/main.go +++ b/main.go @@ -75,8 +75,6 @@ func realMain() int { log.Fatalf("Failed parsing parameter flag: can only be resp or json") } - redisPassword := os.Getenv("REDISDUMPGO_AUTH") - progressNotifs := make(chan redisdump.ProgressNotification) var wg sync.WaitGroup wg.Add(1) @@ -113,7 +111,7 @@ func realMain() int { Host: c.Host, Port: c.Port, Username: c.Username, - Password: redisPassword, + Password: c.Password, TlsHandler: tlshandler, } diff --git a/pkg/config/config.go b/pkg/config/config.go index cbacef7..b87033b 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -11,6 +11,7 @@ type Config struct { Port int Db int Username string + Password string Filter string Noscan bool BatchSize int @@ -47,6 +48,7 @@ func FromFlags(progName string, args []string) (Config, string, error) { flags.IntVar(&c.Port, "port", 6379, "Server port") flags.IntVar(&c.Db, "db", -1, "only dump this database (default: all databases)") flags.StringVar(&c.Username, "user", "", "Username") + flags.StringVar(&c.Password, "password", "", "Password") flags.StringVar(&c.Filter, "filter", "*", "Key filter to use") flags.BoolVar(&c.Noscan, "noscan", false, "Use KEYS * instead of SCAN - for Redis <=2.8") flags.IntVar(&c.BatchSize, "batchSize", 1000, "HSET/RPUSH/SADD/ZADD only add 'batchSize' items at a time") From 1b162edaf7e68f5514f0db77404969fe081861f7 Mon Sep 17 00:00:00 2001 From: zhangpanfeng Date: Thu, 30 Nov 2023 15:45:29 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E4=BC=A0=E5=80=BC?= =?UTF-8?q?=E6=96=B9=E5=BC=8Freadme?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Readme.md | 56 ++++++++++++++++++++++++++++++++----------------------- 1 file changed, 33 insertions(+), 23 deletions(-) diff --git a/Readme.md b/Readme.md index aff6d0e..8243565 100644 --- a/Readme.md +++ b/Readme.md @@ -37,37 +37,47 @@ a Github Account might be required / bandwidth costs might be applicable. ``` $ ./bin/redis-dump-go -h Usage of ./bin/redis-dump-go: - -batchSize int + -batchSize int HSET/RPUSH/SADD/ZADD only add 'batchSize' items at a time (default 1000) - -db uint - only dump this database (default: all databases) - -filter string - Key filter to use (default "*") - -host string - Server host (default "127.0.0.1") - -n int - Parallel workers (default 10) - -noscan - Use KEYS * instead of SCAN - for Redis <=2.8 - -output string - Output type - can be resp or commands (default "resp") - -port int - Server port (default 6379) - -s Silent mode (disable logging of progress / stats) - -ttl - Preserve Keys TTL (default true) + -cacert string + CA Certificate file to verify with + -cert string + Private key file to authenticate with + -db int + only dump this database (default: all databases) (default -1) + -filter string + Key filter to use (default "*") + -h show help information + -host string + Server host (default "127.0.0.1") + -insecure + Allow insecure TLS connection by skipping cert validation + -key string + SSL private key file path + -n int + Parallel workers (default 10) + -noscan + Use KEYS * instead of SCAN - for Redis <=2.8 + -output string + Output type - can be resp or commands (default "resp") + -password string + Password + -port int + Server port (default 6379) + -s Silent mode (disable logging of progress / stats) + -tls + Establish a secure TLS connection + -ttl + Preserve Keys TTL (default true) + -user string + Username $ ./bin/redis-dump-go > dump.resp Database 0: 9 element dumped Database 1: 1 element dumped ``` -For password-protected Redis servers, set the shell variable REDISDUMPGO\_AUTH: -``` -$ export REDISDUMPGO_AUTH=myRedisPassword -$ redis-dump-go -``` ## Build