Copying all keys in Redis database using MIGRATE

前端 未结 5 2324
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:23

    For a big DBs with a lot of keys it's better to use --scan instead of keys, to avoid Redis lock on KEYS command:

    redis-cli --scan | xargs redis-cli MIGRATE my.redis 6379 "" 0 5000 KEYS
    

    Not really related to the question, but in case someone will need it: Redis does not support MIGRATE with a password before 3.0. After 3.0, you can add AUTH parameter to check the permission:

    MIGRATE 192.168.0.33 6379 "" 0 5000 AUTH mypassword KEYS user:{info}:age
    

提交回复
热议问题