Last active
August 27, 2024 09:05
-
-
Save fabienduhamel/43c68ee173272d69d33f210ac0cc644b to your computer and use it in GitHub Desktop.
Redis migration script
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/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