{"id":17346,"library":"redis-dump","title":"Redis Database Dump Tool","description":"The `redis-dump` package provides a utility for exporting data from a Redis database, offering output in two primary formats: a series of Redis commands suitable for direct re-import via `redis-cli`, or a structured JSON representation for programmatic processing. The current stable version, `0.1.10`, was last published in March 2014, indicating that the project is no longer actively maintained. Its core functionality enables users to backup, migrate, or inspect Redis data, differentiating itself by supporting both a command-line interface and a programmatic API for Node.js applications. Due to its age, it predates modern JavaScript module systems and may not be compatible with newer Redis features or Node.js versions, and has an effectively non-existent release cadence.","status":"abandoned","version":"0.1.10","language":"javascript","source_language":"en","source_url":"git://github.com/jeremyfa/node-redis-dump","tags":["javascript","redis","dump","database","command line","json"],"install":[{"cmd":"npm install redis-dump","lang":"bash","label":"npm"},{"cmd":"yarn add redis-dump","lang":"bash","label":"yarn"},{"cmd":"pnpm add redis-dump","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"The module exports the Commander.js program object used for parsing CLI arguments. It does NOT export a direct function for dumping Redis data programmatically. To utilize its data dumping functionality from Node.js, you must execute the `redis-dump` command as a child process.","wrong":"import program from 'redis-dump';","symbol":"program","correct":"const program = require('redis-dump');"}],"quickstart":{"code":"const redis = require('redis');\nconst { spawn } = require('child_process');\n\nasync function runDump() {\n    const client = redis.createClient({\n        url: process.env.REDIS_URL || `redis://${process.env.REDIS_HOST || '127.0.0.1'}:${process.env.REDIS_PORT || '6379'}`,\n        password: process.env.REDIS_PASSWORD || ''\n    });\n\n    client.on('error', (err) => {\n        console.error('Redis Client Error', err);\n    });\n\n    try {\n        await client.connect();\n\n        // Populate some dummy data for demonstration\n        await client.del('mydb:numberlist', 'mydb:numberset', 'mydb:numvisits');\n        await client.rPush('mydb:numberlist', 'one', 'two', 'three');\n        await client.sAdd('mydb:numberset', 'one', 'two', 'three');\n        await client.set('mydb:numvisits', '34');\n        console.log('Dummy data populated in Redis.');\n\n        // Define common connection arguments for redis-dump CLI\n        const commonDumpArgs = [\n            '-h', process.env.REDIS_HOST || '127.0.0.1',\n            '-p', process.env.REDIS_PORT || '6379',\n            '-a', process.env.REDIS_PASSWORD || '',\n            '-f', 'mydb:*'\n        ];\n\n        // Dump as JSON\n        console.log('\\n--- Dumping as JSON ---');\n        const jsonDumpProcess = spawn('redis-dump', [...commonDumpArgs, '--json', '--pretty']);\n\n        let jsonOutput = '';\n        jsonDumpProcess.stdout.on('data', (data) => { jsonOutput += data.toString(); });\n        jsonDumpProcess.stderr.on('data', (data) => { console.error(`stderr (JSON dump): ${data}`); });\n        await new Promise((resolve, reject) => {\n            jsonDumpProcess.on('close', (code) => {\n                if (code === 0) { console.log('JSON Dump Output:\\n', jsonOutput); resolve(); }\n                else { reject(new Error(`redis-dump JSON process exited with code ${code}`)); }\n            });\n        });\n\n        // Dump as Redis commands\n        console.log('\\n--- Dumping as Redis Commands ---');\n        const commandDumpProcess = spawn('redis-dump', commonDumpArgs);\n\n        let commandOutput = '';\n        commandDumpProcess.stdout.on('data', (data) => { commandOutput += data.toString(); });\n        commandDumpProcess.stderr.on('data', (data) => { console.error(`stderr (Command dump): ${data}`); });\n        await new Promise((resolve, reject) => {\n            commandDumpProcess.on('close', (code) => {\n                if (code === 0) { console.log('Command Dump Output:\\n', commandOutput); resolve(); }\n                else { reject(new Error(`redis-dump Command process exited with code ${code}`)); }\n            });\n        });\n\n    } catch (error) {\n        console.error('An error occurred:', error);\n    } finally {\n        await client.disconnect();\n        console.log('Redis client disconnected.');\n    }\n}\n\nrunDump();\n","lang":"javascript","description":"This example demonstrates how to use `redis-dump` programmatically by spawning it as a child process to export Redis data in both JSON and Redis command formats, first populating some example data using a modern Redis client."},"warnings":[{"fix":"Consider using actively maintained alternatives like `ioredis` or `node-redis` for programmatic dumping and backup solutions. For CLI-based backups, `redis-cli --rdb` or `redis-cli --scan | xargs redis-cli dump` provide more robust and current options.","message":"The `redis-dump` package is effectively abandoned, with its last publication dating back to March 2014. It is unlikely to be compatible with newer Node.js versions, modern Redis client libraries, or recent Redis server features and data structures, potentially leading to instability or data loss.","severity":"breaking","affected_versions":"<=0.1.10"},{"fix":"When integrating `redis-dump` into a Node.js application, use `require('child_process').spawn('redis-dump', args)` to execute the CLI tool with desired arguments, rather than attempting to call methods directly from the required module.","message":"Despite its description, programmatic usage of `redis-dump` in Node.js is primarily achieved by spawning its command-line interface as a child process (e.g., using `child_process.spawn`). The `require('redis-dump')` statement directly exposes the Commander.js CLI parser object, not a direct function for dumping Redis data.","severity":"gotcha","affected_versions":"<=0.1.10"},{"fix":"Always specify connection details explicitly: `redis-dump -h <host> -p <port> -a <password>`. Use environment variables or a configuration management system to securely handle sensitive data like passwords.","message":"The package defaults to connecting to a Redis server on `127.0.0.1:6379` without authentication. If your Redis instance is configured differently, requires a password, or is not running on the default host/port, you must explicitly provide the correct hostname, port, and authentication parameters via the command line arguments (`-h`, `-p`, `-a`).","severity":"gotcha","affected_versions":"<=0.1.10"},{"fix":"Be aware that importing a generated Redis command dump will overwrite existing data for keys present in the dump. If you need to merge data or selectively restore, manual processing or filtering of the dump file is necessary before importing.","message":"When generating Redis commands, the output includes `DEL` commands before `RPUSH`, `SADD`, `ZADD`, `HMSET`, etc. This behavior ensures a clean slate upon re-import but will unconditionally delete and then recreate keys with matching names, potentially overwriting existing data if not handled carefully.","severity":"gotcha","affected_versions":"<=0.1.10"}],"env_vars":null,"last_verified":"2026-04-22T00:00:00.000Z","next_check":"2026-07-21T00:00:00.000Z","problems":[{"fix":"Install the package globally using `npm install -g redis-dump`. Alternatively, execute it using `npx redis-dump [OPTIONS]` or by referencing its local binary path: `$(npm bin)/redis-dump [OPTIONS]`.","cause":"The `redis-dump` CLI tool is not found in your system's PATH. This typically occurs if the package was installed locally (`npm install redis-dump`) but not globally (`npm install -g redis-dump`), or if `node_modules/.bin` is not in your PATH.","error":"\"redis-dump\" is not recognized as an internal or external command, operable program or batch file."},{"fix":"Ensure your Redis server is running and accessible from the machine where `redis-dump` is executed. Verify the host, port, and password by explicitly passing them to `redis-dump` using the `-h`, `-p`, and `-a` arguments.","cause":"The `redis-dump` tool failed to establish a connection to the Redis server. This usually means the Redis server is not running, is configured to listen on a different host or port, or is blocked by a firewall.","error":"Error: connect ECONNREFUSED 127.0.0.1:6379"},{"fix":"Use CommonJS `require()` syntax to load the module: `const program = require('redis-dump');`. Direct programmatic use of its dumping functionality is limited, as the module exports the Commander.js program object rather than a dump function.","cause":"You are attempting to use `redis-dump`, which is a CommonJS module from 2014, with ES module `import` syntax in a modern Node.js environment or build setup that does not correctly transpile or handle CommonJS imports.","error":"SyntaxError: Unexpected token 'export' or 'import' in redis-dump.js"}],"ecosystem":"npm","meta_description":null}