{"id":13754607,"url":"https://github.com/jeremyfa/node-redis-dump","last_synced_at":"2025-04-04T21:11:16.938Z","repository":{"id":2433164,"uuid":"3402713","full_name":"jeremyfa/node-redis-dump","owner":"jeremyfa","description":"Dump redis database into redis commands or json with command line or node.js","archived":false,"fork":false,"pushed_at":"2021-05-05T18:37:08.000Z","size":50,"stargazers_count":113,"open_issues_count":13,"forks_count":34,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-10-14T22:45:15.370Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jeremyfa.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2012-02-10T00:02:50.000Z","updated_at":"2024-09-10T12:24:10.000Z","dependencies_parsed_at":"2022-09-13T11:41:04.427Z","dependency_job_id":null,"html_url":"https://github.com/jeremyfa/node-redis-dump","commit_stats":null,"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jeremyfa%2Fnode-redis-dump","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jeremyfa%2Fnode-redis-dump/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jeremyfa%2Fnode-redis-dump/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jeremyfa%2Fnode-redis-dump/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jeremyfa","download_url":"https://codeload.github.com/jeremyfa/node-redis-dump/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247249532,"owners_count":20908212,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-03T10:00:30.615Z","updated_at":"2025-04-04T21:11:16.921Z","avatar_url":"https://github.com/jeremyfa.png","language":"JavaScript","readme":"# redis-dump\n\nDump redis database into redis commands or json with command line or node.js\n\n## Installation\n\n### Installing npm (node package manager)\n``` bash\n$ curl http://npmjs.org/install.sh | sh\n```\n\n### Installing redis-dump\n``` bash\n$ [sudo] npm install redis-dump -g\n```\n\n**Note:** If you are using redis-dump _programatically_ you should not install it globally.\n\n``` bash\n$ cd /path/to/your/project\n$ [sudo] npm install redis-dump\n```\n\n## Usage\nThere are two distinct ways to use redis-dump: through the command line interface, or by requiring the redis-dump module in your own code.\n\n### Using redis-dump from the command line\nThe usage options are simple:\n\n```\n$ redis-dump --help\nUsage: redis-dump [OPTIONS]\n  -h \u003chostname\u003e    Server hostname (default: 127.0.0.1)\n  -p \u003cport\u003e        Server port (default: 6379)\n  -a \u003cauth\u003e        Server auth password (default: '')\n  -d \u003cdb\u003e          Database to be selected (default: 0)\n  -f \u003cfilter\u003e      Query filter (default: *)\n  --convert        Convert from json to redis commands\n  --help           Output this help and exit\n  --json           Output result as json\n  --pretty         Make pretty indented output (use with --json)\n\nExamples:\n  redis-dump\n  redis-dump -p 6500\n  redis-dump -p 6500 -a password\n  redis-dump -f 'mydb:*' \u003e mydb.dump.txt\n  redis-dump --json \u003e mydb.json\n\nThe output is a valid list of redis commands.\nThat means the following will work:\n  redis-dump \u003e dump.txt      # Dump redis database\n  cat dump.txt | redis-cli   # Import redis database from generated file\n```\n\n### Example\nLet's say we have created a brand new redis database and have got the data generated from these commands:\n\n```\nRPUSH   mydb:numberlist one two three\nSADD    mydb:numberset one two three\nZADD    mydb:sortednumberset 1000 one 2000 two 3000 three\nHMSET   mydb:article:4 title 'Hello World' id 4\nSET     mydb:numvisits 34\nSET     mydb:volatile 'nothing important'\nEXPIRE  mydb:volatile 3600\n```\n\nIf we call redis-dump, the output will look like this:\n\n``` bash\n$ redis-dump -f 'mydb:*'\nDEL     mydb:numberlist\nRPUSH   mydb:numberlist one two three\nDEL     mydb:numberset\nSADD    mydb:numberset three two one\nDEL     mydb:sortednumberset\nZADD    mydb:sortednumberset 1000 one 2000 two 3000 three\nDEL     mydb:article:4\nHMSET   mydb:article:4 title 'Hello World' id 4\nSET     mydb:numvisits 34\nDEL     mydb:volatile\nSET     mydb:volatile 'nothing important'\nEXPIRE  mydb:volatile 3600\n```\n\nAnd with json output:\n\n``` bash\n$ redis-dump -f 'mydb:*' --json\n{\"mydb:numberlist\":{\"type\":\"list\",\"value\":[\"one\",\"two\",\"three\"]},\"mydb:numberset\":{\"type\":\"set\",\"value\":[\"three\",\"two\",\"one\"]},\"mydb:sortednumberset\":{\"type\":\"zset\",\"value\":[[1000,\"one\"],[2000,\"two\"],[3000,\"three\"]]},\"mydb:volatile\":{\"type\":\"string\",\"value\":\"nothing important\",\"ttl\":3466},\"mydb:article:4\":{\"type\":\"hash\",\"value\":{\"title\":\"Hello World\",\"id\":\"4\"}},\"mydb:numvisits\":{\"type\":\"string\",\"value\":\"34\"}}\n\n$ redis-dump -f 'mydb:*' --json --pretty \u003e mydb.json\n```\n\nThe json maps all the informations from redis database in a handy way for other programming languages.\n\n``` js\n{\n    \"mydb:numberlist\": {\n        \"type\": \"list\",\n        \"value\": [\n            \"one\",\n            \"two\",\n            \"three\"\n        ]\n    },\n    \"mydb:numberset\": {\n        \"type\": \"set\",\n        \"value\": [\n            \"three\",\n            \"two\",\n            \"one\"\n        ]\n    },\n    \"mydb:sortednumberset\": {\n        \"type\": \"zset\",\n        \"value\": [\n            [\n                1000,\n                \"one\"\n            ],\n            [\n                2000,\n                \"two\"\n            ],\n            [\n                3000,\n                \"three\"\n            ]\n        ]\n    },\n    \"mydb:volatile\": {\n        \"type\": \"string\",\n        \"value\": \"nothing important\",\n        \"ttl\": 3466\n    },\n    \"mydb:article:4\": {\n        \"type\": \"hash\",\n        \"value\": {\n            \"title\": \"Hello World\",\n            \"id\": \"4\"\n        }\n    },\n    \"mydb:numvisits\": {\n        \"type\": \"string\",\n        \"value\": \"34\"\n    }\n}\n```\n\nYou can also convert json back to redis commands.\n\n``` bash\n$ cat mydb.json | redis-dump --convert\nDEL     mydb:numberlist\nRPUSH   mydb:numberlist one two three\nDEL     mydb:numberset\nSADD    mydb:numberset three two one\nDEL     mydb:sortednumberset\nZADD    mydb:sortednumberset 1000 one 2000 two 3000 three\nDEL     mydb:article:4\nHMSET   mydb:article:4 title 'Hello World' id 4\nSET     mydb:numvisits 34\nDEL     mydb:volatile\nSET     mydb:volatile 'nothing important'\nEXPIRE  mydb:volatile 3466\n```\n\nThen, import your data back to redis can be done in one line from either format:\n\n``` bash\n$ cat mydb.json | redis-dump --convert | redis-cli # from json\n\n$ cat dump.txt | redis-cli # from redis commands\n```\n\n### Using redis-dump from node.js\nYou can also use redis-dump from inside your own node.js code.\n\n``` js\nvar dump = require('redis-dump');\n\ndump({\n  // These are default values, you can omit them\n  filter: '*',\n  port: 6379,\n  host: '127.0.0.1'\n},\nfunction(err, result){\n  // Do something with result\n});\n```\n\n## License\n\n(The MIT License)\n\nCopyright (c) 2011-2012 Jérémy Faivre \u0026lt;contact@jeremyfa.com\u0026gt;\n\nPermission is hereby granted, free of charge, to any person obtaining\na copy of this software and associated documentation files (the\n'Software'), to deal in the Software without restriction, including\nwithout limitation the rights to use, copy, modify, merge, publish,\ndistribute, sublicense, and/or sell copies of the Software, and to\npermit persons to whom the Software is furnished to do so, subject to\nthe following conditions:\n\nThe above copyright notice and this permission notice shall be\nincluded in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,\nEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\nIN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY\nCLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,\nTORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\nSOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n","funding_links":[],"categories":["3. 命令行程序"],"sub_categories":["3.2 推荐"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjeremyfa%2Fnode-redis-dump","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjeremyfa%2Fnode-redis-dump","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjeremyfa%2Fnode-redis-dump/lists"}