-
-
Save josegonzalez/6049a72cb163337a18102743061dfcac to your computer and use it in GitHub Desktop.
Revisions
-
josegonzalez revised this gist
Nov 4, 2024 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -34,7 +34,7 @@ def migrate_redis(source, destination): print("Dumping key: %s" % key) value = src.dump(key) if not value: print("Skipping none") continue print("Restoring key: %s" % key) -
josegonzalez revised this gist
Oct 2, 2024 . 1 changed file with 3 additions and 3 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -31,17 +31,17 @@ def migrate_redis(source, destination): # we handle TTL command returning -1 (no expire) or -2 (no key) if ttl < 0: ttl = 0 print("Dumping key: %s" % key) value = src.dump(key) if not value: print "Skipping none" continue print("Restoring key: %s" % key) try: dst.restore(key, ttl * 1000, value, replace=True) except redis.exceptions.ResponseError: print("Failed to restore key: %s" % key) pass return -
josegonzalez revised this gist
Aug 12, 2023 . 1 changed file with 4 additions and 0 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -33,6 +33,10 @@ def migrate_redis(source, destination): ttl = 0 print "Dumping key: %s" % key value = src.dump(key) if not value: print "Skipping none" continue print "Restoring key: %s" % key try: dst.restore(key, ttl * 1000, value, replace=True) -
josegonzalez revised this gist
Mar 7, 2017 . 1 changed file with 5 additions and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -34,7 +34,11 @@ def migrate_redis(source, destination): print "Dumping key: %s" % key value = src.dump(key) print "Restoring key: %s" % key try: dst.restore(key, ttl * 1000, value, replace=True) except redis.exceptions.ResponseError: print "Failed to restore key: %s" % key pass return -
iserko revised this gist
Feb 27, 2014 . 1 changed file with 0 additions and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -35,7 +35,6 @@ def migrate_redis(source, destination): value = src.dump(key) print "Restoring key: %s" % key dst.restore(key, ttl, value) return -
iserko revised this gist
Feb 27, 2014 . 1 changed file with 3 additions and 0 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -28,6 +28,9 @@ def migrate_redis(source, destination): dst = connect_redis(destination) for key in src.keys('*'): ttl = src.ttl(key) # we handle TTL command returning -1 (no expire) or -2 (no key) if ttl < 0: ttl = 0 print "Dumping key: %s" % key value = src.dump(key) print "Restoring key: %s" % key -
iserko revised this gist
Feb 27, 2014 . 1 changed file with 2 additions and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -27,10 +27,11 @@ def migrate_redis(source, destination): src = connect_redis(source) dst = connect_redis(destination) for key in src.keys('*'): ttl = src.ttl(key) print "Dumping key: %s" % key value = src.dump(key) print "Restoring key: %s" % key dst.restore(key, ttl, value) return return -
iserko revised this gist
Feb 27, 2014 . 1 changed file with 6 additions and 2 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -26,8 +26,12 @@ def conn_string_type(string): def migrate_redis(source, destination): src = connect_redis(source) dst = connect_redis(destination) for key in src.keys('*'): print "Dumping key: %s" % key value = src.dump(key) print "Restoring key: %s" % key dst.restore(key, 0, value) return return -
iserko created this gist
Feb 27, 2014 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,42 @@ #!/usr/bin/env python import argparse import redis def connect_redis(conn_dict): conn = redis.StrictRedis(host=conn_dict['host'], port=conn_dict['port'], db=conn_dict['db']) return conn def conn_string_type(string): format = '<host>:<port>/<db>' try: host, portdb = string.split(':') port, db = portdb.split('/') db = int(db) except ValueError: raise argparse.ArgumentTypeError('incorrect format, should be: %s' % format) return {'host': host, 'port': port, 'db': db} def migrate_redis(source, destination): src = connect_redis(source) dst = connect_redis(destination) print "test_key src", src.get('test_key') print "test_key dst", dst.get('test_key') return def run(): parser = argparse.ArgumentParser() parser.add_argument('source', type=conn_string_type) parser.add_argument('destination', type=conn_string_type) options = parser.parse_args() migrate_redis(options.source, options.destination) if __name__ == '__main__': run()