Problem: Redis in Cloud, or local, data migration from server1 to server2, using dump.rdb file not working
My Solution:
Step 1. create the dump file, dump.rdb:
Run the create dump command in redis-cli: BGSAVE
Identify the dump dir, command in redis-cli: config get dir response e.g: /data
Step 2. Copy the dump.rdf file from the source to the destination redis server (k8s container with redis or local redis server, use config get dir to identify the folder path)
Step 3. Disable AOF(append only file). Redis uses 2 systems for storing data. One that uses a file to keep records (dump.rdb), or an event sourcing system, style called AOF. AOF is used by default. For migration using a dump file, we need to disable the AOF system. For this, create a text file: redis.config and add a single line:
appendonly no
Step 4. Start the redis server with the config file as command argument. In order to specify a config file run the server with the config file:
redis-server /path/to/redis.conf
Step 5. Validation- Redis will automatically load the dump file. Connect to redis and query for keys, or check the logs for the number of imported entries (e.g keys loaded: 6513):
1:M 23 May 2024 05:56:20.243 * RDB age 4002 seconds 1:M 23 May 2024 05:56:20.243 * RDB memory usage when created 7.22 Mb 1:M 23 May 2024 05:56:20.629 * Done loading RDB, keys loaded: 6513, keys expired: 0.
PS: also a good article: https://www.digitalocean.com/community/tutorials/how-to-back-up-and-restore-your-redis-data-on-ubuntu-14-04
Good Luck !