Registry / database / redis-drs

redis-drs

JSON →
library1.3.11jsnpmunverified

redis-drs is a Redis Dump, Restore and Sync tool built on ioredis, supporting all Redis data types with TTL handling. Current stable version is 1.3.11, with regular releases on npm. It provides CLI commands and a TypeScript-friendly programmatic API. Unlike alternatives, it produces human-readable, line-aligned dumps and can stream data, making it suitable for large-scale backups. It supports dump/restore/sync operations with pattern filtering and configurable bulk sizes.

npm install redis-drs
INSTALL
IMPORT
SIG · REDIS-DRS
R
redis-drs
databasejavascriptv1.3.11
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

RedisDRS
✓ import { RedisDRS } from 'redis-drs'
✗ const RedisDRS = require('redis-drs')
ESM-only since v1; CommonJS require may work with Node.js >=12, but TypeScript types assume ESM. Use import syntax.

Demonstrates dump and restore operations using RedisDRS with pattern filtering and TTL preservation.

import { RedisDRS } from 'redis-drs'; const redis = new RedisDRS({ path: 'redis://localhost:6379/0' }); async function dumpAndRestore() { const dumpIter = redis.dump({ filePath: 'dump.csv', pattern: '*' }); const total = (await dumpIter.next()).value as number; console.log(`Total keys: ${total}`); for await (const _ of dumpIter) {} const restoreIter = await redis.restore({ filePath: 'dump.csv', useTtl: true, bulkSize: 1000 }); const totalRestore = (await restoreIter.next()).value as number; console.log(`Restored keys: ${totalRestore}`); for await (const _ of restoreIter) {} redis.disconnect(); } dumpAndRestore().catch(console.error);
Debug
Known issues
gotchaThe dump iterator returns total keys as the first yield; must consume it for correct streaming.
fix
Always call .next() once and get the total, then iterate over the rest.
affects: >=1.0
gotchaRestore and sync also yield total keys as first value; forgetting to consume it breaks iteration.
fix
Always consume the first value from the async generator.
affects: >=1.0
deprecatedConstructor options 'uri' deprecated in favor of 'path'.
fix
Use 'path' instead of 'uri' in RedisDRS constructor.
affects: >=1.1
breakingDump file format changed between 1.0.x and 1.1.x; incompatible with old dumps.
fix
Regenerate dump files using new version.
affects: >=1.1,<2.0
gotchasync() does not accept a Redis connection instance; must use targetRedisOptions.
fix
Pass 'targetRedisOptions' object with 'path' instead of a Redis connection.
affects: >=1.0
gotchaCLI commands require global install; local install without -g will not expose 'redis-drs' command.
fix
Use 'npx redis-drs' or install globally with 'npm i -g redis-drs'.
affects: >=1.0
Errors
Common errors & fixes
TypeError: redis.dump is not a function
library not imported correctly; CommonJS require leads to wrong export.
fix
Use import { RedisDRS } from 'redis-drs'
Error: ERR unknown command 'RESTORE'
redis server version too old or not enabled; RESTORE requires Redis >=2.6.
fix
Upgrade Redis server to 2.6+ or use a compatible cloud instance.
Error: ENOENT: no such file or directory, open 'dump.csv'
File path is relative; script may run from a different working directory.
fix
Use an absolute path or ensure correct working directory.
Error: Connection is closed
Redis connection is closed before async iteration completes.
fix
Ensure redis.disconnect() is called after all async operations finish.
Upgrade
Version history
1.3.11latest on npm
Audit
Dependencies
ioredisrequiredCore dependency: all Redis operations use ioredis for connection and commands.
Agent activity
5 hits · last 30 days
node
4
Resources
redis-drs — npm install redis-drs · libregistry