This script is used to migrate Redis data from one server to another. It supports custom ports, passwords, and the ability to select specific Redis databases to transfer.
Before using the redis-migrate.sh
script, ensure that you have the following dependencies installed on your system:
wget
: Used for retrieving files from the web (if your script requires it).redis-tools
: Provides necessary tools for interacting with Redis, such asredis-cli
.
Before running the script, make sure you have the necessary permissions to execute it. You can set the execution permission using the following command:
chmod +x redis-migrate.sh
To migrate Redis data, run the script with the appropriate options as shown in the example below:
./redis-migrate.sh \
--src-host "redis-01" \ # Source Redis server host
--src-port "6379" \ # Source Redis server port
--src-password "password123" \ # Source Redis server password, if required
--dest-host "localhost" \ # Destination Redis server host
--dest-port "6379" \ # Destination Redis server port
--dest-password "password456" \ # Destination Redis server password, if required
--dbs "1,0" # Comma-separated list of database indexes to migrate
Replace password123
and password456
with the actual passwords for your source and destination Redis instances, respectively. If there is no password, you can simply omit the --src-password
and --dest-password
options or leave them empty like this --src-password ""
.
The --dbs
option allows you to specify which databases to migrate. In the example above, databases with indexes 1 and 0 will be migrated. If you want to migrate all databases, you can omit this option.
- Make sure that the source and destination Redis servers are accessible from the host where the script is running.
- Verify that there is enough network bandwidth and the destination Redis server has sufficient memory to handle the data being migrated.
- It is recommended to perform the migration during a maintenance window or when the load on the Redis servers is minimal to avoid any performance impact.
Remember to customize the command with the actual data from your environment.