Skip to content

Instantly share code, notes, and snippets.

@stephanustedy
Last active April 22, 2020 12:17
Show Gist options
  • Save stephanustedy/eb1d0c0daf5cc83373513b1f6980be52 to your computer and use it in GitHub Desktop.
Save stephanustedy/eb1d0c0daf5cc83373513b1f6980be52 to your computer and use it in GitHub Desktop.

Revisions

  1. stephanustedy revised this gist Apr 22, 2020. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion command for copy redis
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,5 @@
    # 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]; done;
    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
  2. stephanustedy revised this gist Apr 22, 2020. No changes.
  3. stephanustedy revised this gist Apr 22, 2020. 1 changed file with 3 additions and 3 deletions.
    6 changes: 3 additions & 3 deletions command for copy redis
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,5 @@
    # 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;
    while true; do exec redis-cli -h [old-endpoint] monitor | sed -u 's/.*]//' | grep -vi "get\|ping" | redis-cli -h [new-endpoint]; done;

    # COPY DATA ON REDIS
    redis-cli -h [old-endpoint] --scan | while read key; do echo "Copying $key"; redis-cli -h [old-endpoint] --raw DUMP "$key" | head -c -1 |redis-cli -x -h [new-endpoint] RESTORE "$key" 0; done >> /dev/null
    # 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
  4. stephanustedy created this gist May 7, 2019.
    5 changes: 5 additions & 0 deletions command for copy redis
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,5 @@
    # 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
    redis-cli -h [old-endpoint] --scan | while read key; do echo "Copying $key"; redis-cli -h [old-endpoint] --raw DUMP "$key" | head -c -1 |redis-cli -x -h [new-endpoint] RESTORE "$key" 0; done >> /dev/null