Last active
April 22, 2020 12:17
-
-
Save stephanustedy/eb1d0c0daf5cc83373513b1f6980be52 to your computer and use it in GitHub Desktop.
command for copy redis
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
| # COPY REAL TIME / NEW DATA | |
| while true; do exec redis-cli -h [old-endpoint] monitor | sed -u 's/.*]//' | grep -vi "get\|ping" | redis-cli -h [new-endpoint] >> /dev/null; done; | |
| # COPY DATA ON REDIS with TTL | |
| redis-cli -h [old-endpoint] --scan | while read key; do tempTTL=$(redis-cli -h [old-endpoint] TTL "$key"); ttl=$tempTTL;if [ $tempTTL -lt 0 ]; then ttl=0; fi; redis-cli -h [old-endpoint] --raw DUMP "$key" | head -c -1 |redis-cli -x -h [new-endpoint] RESTORE "$key" $ttl; echo "copied $key $ttl"; done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment