Redis Shell is an enhanced interactive command-line interface for Redis that goes beyond the standard redis-cli. It provides a rich set of features including multi-connection management, data import/export, cluster management, and an extensible plugin architecture.
- Installation
- Quick Start
- Basic Usage
- Advanced Features
- Built-in Extensions
- Configuration
- Tips and Best Practices
Create a standalone executable using PEX:
# Install PEX in a virtual environment
uv venv
source .venv/bin/activate # On Windows: .venv\Scripts\activate
uv pip install pex
# Create the executable
pex . -D . -e redis_shell.__main__:main -o redis-shell.pex --venv --strip-pex-env --no-compile --no-wheel --compress
# Run it
./redis-shell.pexTo include your custom extensions in the executable:
pex . -D . -D $HOME/.config/redis-shell/extensions -r $HOME/.config/redis-shell/extensions/*/requirements.txt -e redis_shell.__main__:main -o redis-shell.pex --venv --strip-pex-env --no-compile --no-wheel --compressIf you want to contribute or modify the code:
# Clone the repository
git clone <repository-url>
cd redis-shell
# Create virtual environment and install
uv venv
source .venv/bin/activate # On Windows: .venv\Scripts\activate
uv pip install -e .
# Run directly
redis-shell# Connect to local Redis (default: localhost:6379)
redis-shell
# Connect to remote Redis
redis-shell --host redis.example.com --port 6379 --password mypassword
# Connect with SSL
redis-shell --host secure-redis.com --port 6380 --ssl --ssl-cert-reqs requiredOnce connected, you can use Redis Shell like the standard Redis CLI, but with enhanced features:
# Standard Redis commands work as expected
localhost:6379> SET mykey "Hello World"
OK
localhost:6379> GET mykey
"Hello World"
# Use shell commands (starting with /)
localhost:6379> /help
Available commands:
/clear - Clear screen
/exit - Exit shell
/help - Show help message
/history - Show command history
# Use built-in extensions
localhost:6379> /data export --pattern "user:*"
Exporting keys matching pattern 'user:*'...
Export completed: redis-export-20240118-143022-localhost-6379.txt- Use Up/Down arrows to navigate command history
- Use
/historyto view all previous commands - Use
/history <number>to re-run a specific command - Use
/history clearto clear the history
- Press Tab to see available commands and options
- Works for Redis commands, shell commands, and extension commands
- Context-aware completion for file paths, connection IDs, etc.
- Use
/clearto clear the screen - Use Ctrl+C to cancel current input
- Use
/exitor Ctrl+D to exit the shell
Redis Shell supports three types of commands:
- Redis Commands: Standard Redis commands (GET, SET, HGET, etc.)
- Shell Commands: Built-in shell utilities (starting with
/) - Extension Commands: Commands provided by extensions (e.g.,
/data export)
Set these environment variables to configure default connection settings:
export REDIS_HOST=redis.example.com
export REDIS_PORT=6379
export REDIS_DB=0
export REDIS_USERNAME=myuser
export REDIS_PASSWORD=mypassword
export REDIS_SHELL_LOG_LEVEL=infoRedis Shell can manage multiple Redis connections simultaneously:
# Create additional connections
localhost:6379> /connection create --host redis2.example.com --port 6379
Connection created with ID: 2
localhost:6379> /connection create --host redis-cluster.example.com --port 7000
Connection created with ID: 3
# List all connections
localhost:6379> /connection list
Connections:
* 1: localhost:6379 (db: 0)
2: redis2.example.com:6379 (db: 0)
3: redis-cluster.example.com:7000 (db: 0)
# Switch between connections
localhost:6379> /connection use 2
Switched to connection 2
redis2.example.com:6379>
# Remove a connection
redis2.example.com:6379> /connection destroy 3
Connection 3 destroyed# Export all keys
localhost:6379> /data export
# Export keys matching a pattern
localhost:6379> /data export --pattern "user:*"
# Export to a specific folder
localhost:6379> /data export --folder /tmp/backups
# Force using KEYS command (faster but blocks Redis)
localhost:6379> /data export --force-keys
# Check export status
localhost:6379> /data status# Import from a file
localhost:6379> /data import --file redis-export-20240118-143022-localhost-6379.txt
# The import process will show progress and handle different data typesRedis Shell supports secure connections:
# Basic SSL connection
redis-shell --host secure-redis.com --port 6380 --ssl
# SSL with custom certificates
redis-shell --host secure-redis.com --port 6380 --ssl \
--ssl-ca-certs /path/to/ca.crt \
--ssl-certfile /path/to/client.crt \
--ssl-keyfile /path/to/client.key
# SSL with different certificate requirements
redis-shell --host secure-redis.com --port 6380 --ssl --ssl-cert-reqs optionalRedis Shell comes with several powerful built-in extensions:
- Export: Export Redis data with pattern matching
- Import: Import data from exported files
- Status: Monitor export/import operations
- Create: Create new Redis connections
- List: List all available connections
- Use: Switch between connections
- Destroy: Remove connections
- Deploy: Deploy a local Redis cluster for testing
- Info: Get cluster information
- Start/Stop: Control cluster lifecycle
- Remove: Clean up cluster resources
- Deploy: Deploy a Redis Sentinel setup
- Info: Get Sentinel information
- Start/Stop: Control Sentinel lifecycle
- Remove: Clean up Sentinel resources
- Get: Retrieve configuration values
- Set: Modify configuration values
- Save: Persist configuration changes
Redis Shell looks for configuration files in this order:
- Path specified by
REDIS_SHELL_CONFIGenvironment variable ~/.redis-shell~/.config/redis-shell/config.json/etc/redis-shell/config.json
{
"general": {
"history_size": 100,
"log_level": "info",
"log_file": null,
"state_file": "~/.redis-shell"
},
"redis": {
"default_host": "127.0.0.1",
"default_port": 6379,
"default_db": 0,
"default_username": "default",
"default_password": "",
"timeout": 5,
"decode_responses": false,
"ssl": false
},
"extensions": {
"extension_dir": "~/.config/redis-shell/extensions"
},
"ui": {
"prompt_style": "green",
"error_style": "red",
"warning_style": "yellow",
"success_style": "green",
"info_style": "blue"
}
}- Use SCAN instead of KEYS: The data export extension uses SCAN by default, which is safer for production
- Pattern Matching: Use specific patterns when exporting to reduce data transfer
- Connection Pooling: Reuse connections instead of creating new ones frequently
- Use SSL/TLS: Always use encrypted connections in production
- Environment Variables: Store sensitive information like passwords in environment variables
- Certificate Validation: Use proper certificate validation in production environments
- Command History: Use
/historyto review and rerun complex commands - Tab Completion: Leverage autocompletion to discover available options
- Multiple Connections: Use connection management for working with multiple Redis instances
- Configuration: Set up a configuration file for frequently used settings
- Connection Issues: Check network connectivity and Redis server status
- SSL Problems: Verify certificate paths and permissions
- Extension Errors: Check extension directory permissions and file structure
- Performance: Monitor Redis server resources during large operations
For more detailed troubleshooting, see the Troubleshooting Guide.