# redis-cli-tool **Repository Path**: JiangBeiQingYi/redis-cli-tool ## Basic Information - **Project Name**: redis-cli-tool - **Description**: Redis CLI tool - **Primary Language**: Java - **License**: Apache-2.0 - **Default Branch**: master - **Homepage**: https://github.com/leonchen83/redis-cli-tool - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 12 - **Created**: 2018-07-20 - **Last Updated**: 2020-12-19 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # redis-cli-tool ## Binary release [binary releases](https://github.com/leonchen83/redis-cli-tool/releases) ## Runtime requirement ```java jdk 1.8+ ``` ## Compile requirement ```java jdk 1.8+ maven-3.3.1+ ``` ## Compile & run ```java cd redis-cli-tool mvn clean install -Dmaven.test.skip=true cd target/redis-cli-tool/bin ./rct -h ``` ## Windows Environment Variables Add `/path/to/redis-cli-tool/bin` to `Path` environment variable ## Usage ```java usage: rct -f -s -o [-d ] [-e ] [-k ] [-t ] [-b ] [-l ] [-r] options: -b,--bytes limit memory output(--format mem) to keys greater to or equal to this value (in bytes) -d,--db database number. multiple databases can be provided. if not specified, all databases will be included. -e,--escape escape strings to encoding: raw (default), redis. -f,--format format to export. valid formats are json, dump, diff, key, keyval, mem and resp -h,--help rct usage. -k,--key keys to export. this can be a regex. if not specified, all keys will be returned. -l,--largest limit memory output(--format mem) to only the top n keys (by size). -o,--out output file. -r,--replace whether the generated aof with parameter(--format dump). if not specified, default value is false. -s,--source eg: /path/to/dump.rdb redis://host:port?authPassword=foobar redis:///path/to/dump.rdb. -t,--type data type to export. possible values are string, hash, set, sortedset, list, module, stream. multiple types can be provided. if not specified, all data types will be returned. -v,--version rct version. examples: rct -f dump -s ./dump.rdb -o ./appendonly.aof -r rct -f resp -s redis://127.0.0.1:6379 -o ./target.aof -d 0 1 rct -f json -s ./dump.rdb -o ./target.json -k user.* product.* rct -f mem -s ./dump.rdb -o ./target.aof -e redis -t list -l 10 -b 1024 ``` ```java usage: rmt -s -m [-d ] [-k ] [-t ] [-r] options: -d,--db database number. multiple databases can be provided. if not specified, all databases will be included. -h,--help rmt usage. -k,--key keys to export. this can be a regex. if not specified, all keys will be returned. -m,--migrate migrate to uri. eg: redis://host:port?authPassword=foobar. -r,--replace replace exist key value. if not specified, default value is false. -s,--source eg: /path/to/dump.rdb redis://host:port?authPassword=foobar redis:///path/to/dump.rdb -t,--type data type to export. possible values are string, hash, set, sortedset, list, module, stream. multiple types can be provided. if not specified, all data types will be returned. -v,--version rmt version. examples: rmt -s redis://120.0.0.1:6379 -m redis://127.0.0.1:6380 -d 0 rmt -s ./dump.rdb -m redis://127.0.0.1:6380 -t string -r ``` ```java usage: rdt [-b | -s -c | -m ] -o [-d ] [-k ] [-t ] options: -b,--backup backup to local rdb file. eg: /path/to/dump.rdb redis://host:port?authPassword=foobar redis:///path/to/dump.rdb -c,--config redis cluster's file(--split ). -d,--db database number. multiple databases can be provided. if not specified, all databases will be included. -h,--help rdt usage. -k,--key keys to export. this can be a regex. if not specified, all keys will be returned. -m,--merge merge multi rdb files to one rdb file. -o,--out if --backup or --merge specified. the is the target file. if --split specified. the is the target path. -s,--split split rdb to multi rdb files via cluster's . eg: /path/to/dump.rdb redis://host:port?authPassword=foobar redis:///path/to/dump -t,--type data type to export. possible values are string, hash, set, sortedset, list, module, stream. multiple types can be provided. if not specified, all data types will be returned. -v,--version rdt version. examples: rdt -b ./dump.rdb -o ./dump.rdb1 -d 0 1 rdt -b redis://127.0.0.1:6379 -o ./dump.rdb -k user.* rdt -m ./dump1.rdb ./dump2.rdb -o ./dump.rdb -t hash rdt -s ./dump.rdb -c ./nodes.conf -o /path/to/folder -t hash -d 0 rdt -s redis://127.0.0.1:6379 -c ./nodes.conf -o /path/to/folder -d 0 ``` ## Filter `rct`, `rdt` and `rmt` all these commands support data filter by `type`,`db`,`key` RegEx. For example: ```java rct -f dump -s /path/to/dump.rdb -o /path/to/dump.aof -d 0 rct -f dump -s /path/to/dump.rdb -o /path/to/dump.aof -t string hash rmt -s /path/to/dump.rdb -m redis://192.168.1.105:6379 -r -d 0 1 -t list ``` ## Redis mass insertion ```java rct -f dump -s /path/to/dump.rdb -o /path/to/dump.aof -r cat /path/to/dump.aof | /redis/src/redis-cli -p 6379 --pipe ``` ## Convert rdb to dump format ```java rct -f dump -s /path/to/dump.rdb -o /path/to/dump.aof ``` ## Convert rdb to json format ```java rct -f json -s /path/to/dump.rdb -o /path/to/dump.json ``` ## Find top 50 largest keys ```java rct -f mem -s /path/to/dump.rdb -o /path/to/dump.mem -l 50 ``` ## Diff rdb ```java rct -f diff -s /path/to/dump1.rdb -o /path/to/dump1.diff rct -f diff -s /path/to/dump2.rdb -o /path/to/dump2.diff diff /path/to/dump1.diff /path/to/dump2.diff ``` ## Convert rdb to RESP ```java rct -f resp -s /path/to/dump.rdb -o /path/to/appendonly.aof ``` ## Migrate rdb to remote redis ```java rmt -s /path/to/dump.rdb -m redis://192.168.1.105:6379 -r ``` ## Backup remote redis's rdb ```java rdt -b redis://192.168.1.105:6379 -o /path/to/dump.rdb ``` ## Filter rdb ```java rdt -b /path/to/dump.rdb -o /path/to/filtered-dump.rdb -d 0 -t string ``` ## Split rdb via cluster's nodes.conf ```java rdt -s ./dump.rdb -c ./nodes.conf -o /path/to/folder -d 0 ``` ## Merge multi rdb to one ```java rdt -m ./dump1.rdb ./dump2.rdb -o ./dump.rdb -t hash ```