0

I am trying to copy all my keys from DB 1 to DB 2 in my redis. I am using following command:

select 1 to switch to DB 1

MIGRATE localhost 6380 "" 2 50000 AUTH my_password COPY KEYS

This throws NOKEY error. Can anyone tell me what is going wrong?

1 Answers1

0

Because you didn't specify any key to be migrated.

Since you used the KEYS option, you need to specify keys after this option:

MIGRATE localhost 6380 "" 2 50000 AUTH my_password  COPY KEYS key1 key2 key3 ...

So in order to migrate keys from one db to another, you need to scan these keys from the source db first.

Also, in your case, you don't need MIGRATE command, but the COPY command, if you're using Redis 6.2.0 or later.

Try the following one-liner:

redis-cli --scan | xargs -I {} redis-cli copy {} {} DB 2
for_stack
  • 21,012
  • 4
  • 35
  • 48