Copying all keys in Redis database using MIGRATE

前端 未结 5 2294
Happy的楠姐
Happy的楠姐 2021-02-20 08:13

Is it possible to copy all keys from one Redis instance to another remote instance using MIGRATE? I\'ve tried COPY, REPLACE and KEYS

5条回答
  •  面向向阳花
    2021-02-20 08:50

    This is an improvement on the answer provided by @ezain since I am unable to post comments. The command uses the correct redis syntax for processing batches of keys, but the arguments to xargs result in the command being called once for every key instead of just once with all the keys included (which means it'll take much more time to complete than is necessary). The following will be much faster in all cases:

    redis-cli --raw KEYS '*' | xargs redis-cli MIGRATE my.redis 6379 "" 0 5000 KEYS

    If the destination is password protected:

    • redis-cli --raw KEYS '*' | xargs redis-cli MIGRATE my.redis 6379 "" 0 5000 AUTH password-here KEYS

提交回复
热议问题