Skip to content

Instantly share code, notes, and snippets.

@fabienduhamel
Last active August 27, 2024 09:05
Show Gist options
  • Select an option

  • Save fabienduhamel/43c68ee173272d69d33f210ac0cc644b to your computer and use it in GitHub Desktop.

Select an option

Save fabienduhamel/43c68ee173272d69d33f210ac0cc644b to your computer and use it in GitHub Desktop.
Redis migration script
#!/bin/bash
#set connection data accordingly
source_host=xxx
source_port=6379
target_host=localhost
target_port=6379
#copy all keys without preserving ttl!
redis-cli -h $source_host -p $source_port keys \* | while read key; do
echo "Copying $key"
redis-cli --raw -h $source_host -p $source_port DUMP "$key" \
| head -c -1 \
| redis-cli -x -h $target_host -p $target_port RESTORE "$key" 0
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment