Skip to content

ahmadarafaa/redisync

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 

Repository files navigation

Redisync: Redis Data Migration Tool

Redisync

Overview

Redisync is a Python script that facilitates data migration between Redis instances or clusters. It connects to source and target Redis instances, identifies master nodes, and securely migrates data, ensuring a smooth transition between environments.

Features

- Multi-Cluster Support: Migrate data across different Redis clusters.

- Password Authentication: Secure connections with password protection.

- Logging: Comprehensive logging to track the migration process.

- Flexible Output: Customize log output (syslog, stdout, or file).

- Config File Support: Use a configuration file for easy setup.

- Command-Line Options: Overwrite config file settings via command-line.

Redisync installation:

curl -sLo redisync https://github.com/ahmadarafaa/redisync/releases/download/$(curl -s https://api.github.com/repos/ahmadarafaa/redisync/releases/latest | grep tag_name | cut -d '"' -f 4)/redisync

Setup and Configuration

  • Dependencies: Ensure the Redis module is installed:

    python3 -m pip install redis
  • Configuration: Configuration File: Use /etc/redisync.conf for settings or provide a custom path.

  • Command-Line Overrides: Modify settings for a single run with command-line arguments.

Configuration Variables

source_hosts: Source Redis IPs (e.g.: 192.168.1.2, 192.168.1.3, 192.168.1.4).
target_hosts: Target Redis IPs (e.g.: 192.168.1.5, 192.168.1.6, 192.168.1.7).
source_password/target_password: Authentication passwords.
output_destination: Log output method (e.g.: file, syslog, stdout)

Usage

  • Run with Python or set up as a cron job:
python3 redisync
  • Use --generate-config-file to create a config template. Command-line options like --source=IPs override config settings.

Configuration file:

$ sudo python3 redisync.py --generate-config-file
Configuration template '/etc/redisync.conf' generated.
$ cat /etc/redisync.conf                         
# Source credentials
[source]
source_hosts = 192.168.1.2, 192.168.1.3, 192.168.1.4
source_password = sourceP@ssw0rd

# Target credentials
[target]
target_hosts = 192.168.1.5, 192.168.1.6, 192.168.7
target_password = targetP@ssw0rd

# Output configuration
[output]
output_destination = syslog

Confiuration Example:

$ sudo python3 redisync.py --help
usage: redisync.py [-h] [--config] [--source] [--source-password] [--target target] [--target-password] [--output] [--generate-config-file]

Redisync: Redis Data Migration Tool

options:
  -h, --help            show this help message and exit
  --config              Path to configuration file, "Default file: /etc/redisync.conf"
  --source              Comma-separated list of source host addresses "It could be one Redis standalone instance"
  --source-password     Password for source Redis instances
  --target target       Comma-separated list of target host addresses "It could be one Redis standalone instance"
  --target-password     Password for target Redis instances
  --output              Output destination: syslog, stdout, or file
  --generate-config-file
                        Generate a template of the default configuration file

Conclusion

Redisync streamlines the Redis data migration process, combining efficiency with security. Whether upgrading your infrastructure or synchronizing data across clusters, Redisync is your go-to tool.

About

Migration tool between Redis instances (standalone or clusters)

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages