def backup_redis(redis_creds, outfile):
    with open(outfile, 'w') as f:
        redisdl.dump(
            f,
            host=redis_creds['host'],
            password=redis_creds['password'],
        )
示例#2
0
def backup_redis(outfile):
    with open(outfile, 'w') as f:
        redisdl.dump(
            f,
            host=config.REDIS_HOST,
            password=config.REDIS_PASSWORD,
        )
示例#3
0
    def test_dump_to_bytesio(self):
        self.r.set('a', 'aaa')

        fp = BytesIO()
        redisdl.dump(fp, keys='a')
        actual = json.loads(fp.getvalue().decode())

        self.assertEqual(actual['a']['value'], 'aaa')
示例#4
0
    def test_dump_to_stringio(self):
        self.r.set('a', 'aaa')

        fp = StringIO()
        redisdl.dump(fp, keys='a')
        actual = json.loads(fp.getvalue())

        self.assertEqual(actual['a']['value'], 'aaa')
示例#5
0
    def test_dump_to_bytesio(self):
        self.r.set("a", "aaa")

        fp = BytesIO()
        redisdl.dump(fp, keys="a")
        actual = json.loads(fp.getvalue().decode())

        self.assertEqual(actual["a"]["value"], "aaa")
示例#6
0
    def test_dump_to_stringio(self):
        self.r.set("a", "aaa")

        fp = StringIO()
        redisdl.dump(fp, keys="a")
        actual = json.loads(fp.getvalue())

        self.assertEqual(actual["a"]["value"], "aaa")
示例#7
0
    def do_dump(options):
        if options.output:
            output = open(options.output, 'w')
        else:
            output = sys.stdout

        kwargs = options_to_kwargs(options)
        dump(output, **kwargs)

        if options.output:
            output.close()
示例#8
0
def dump_redis(PREFIX, date_prefix):
    full_path = os.path.abspath(PREFIX)
    log("Dumping Redis DBs in " + full_path)

    rName2IPDB_path = join(full_path, date_prefix + '-rName2IPDB.json')
    log("writing to " + rName2IPDB_path)
    with open(rName2IPDB_path, 'w') as f:
        redisdl.dump(f, host='localhost', port=6379, db=0)

    rIP2NameDB_path = join(full_path, date_prefix + '-rIP2NameDB.json')
    log("writing to " + rIP2NameDB_path)
    with open(rIP2NameDB_path, 'w') as f:
        redisdl.dump(f, host='localhost', port=6379, db=1)
示例#9
0
    def test_ttl_dump(self):
        self.r.set("a", "aaa")
        self.r.expire("a", 3600)

        start_time = _time.time()
        fp = StringIO()
        redisdl.dump(fp, keys="a")
        end_time = _time.time()
        actual = json.loads(fp.getvalue())

        self.assertGreater(actual["a"]["ttl"], 0)
        self.assertLessEqual(actual["a"]["ttl"], 3600)
        self.assertGreaterEqual(actual["a"]["expireat"], int(start_time) + 3600)
        self.assertLessEqual(actual["a"]["expireat"], int(end_time) + 1 + 3600)
示例#10
0
    def test_ttl_dump(self):
        self.r.set('a', 'aaa')
        self.r.expire('a', 3600)

        start_time = _time.time()
        fp = StringIO()
        redisdl.dump(fp, keys='a')
        end_time = _time.time()
        actual = json.loads(fp.getvalue())

        self.assertGreater(actual['a']['ttl'], 0)
        self.assertLessEqual(actual['a']['ttl'], 3600)
        self.assertGreaterEqual(actual['a']['expireat'],
                                int(start_time) + 3600)
        self.assertLessEqual(actual['a']['expireat'], int(end_time) + 1 + 3600)
import os
import redisdl
import yadisk as ya
from time import gmtime, strftime
OAUTH_KEY = os.getenv('OAUTH_TOKEN')
yadisk = ya.YaDisk(token=os.getenv('OAUTH_TOKEN'))
f = open('temp.json', 'w', encoding='utf8')
json_string = redisdl.dump(f, 'redis')
_time = strftime('%Y_%m_%d_%H', gmtime())
year, month, day, hour = _time.split('_')
try:
    yadisk.mkdir(f'/{year}')
except ya.exceptions.DirectoryExistsError:
    pass
try:
    yadisk.mkdir(f'/{year}/{month}')
except ya.exceptions.DirectoryExistsError:
    pass
try:
    yadisk.mkdir(f'/{year}/{month}/{day}')
except ya.exceptions.DirectoryExistsError:
    pass
f.close()
yadisk.upload('temp.json',
              f'/{year}/{month}/{day}/{hour}.json',
              overwrite=True)
f = open('temp.json', 'w')
f.close()
示例#12
0
 def dump(self):
   with open('%scategories/dump%s.json' % (persistence_path(), self.db), 'w+') as f:
     redisdl.dump(f, db=self.db, host=self.host, port=self.port, encoding='iso-8859-1', pretty=True)
示例#13
0
import os
import redisdl
from dotenv import load_dotenv

load_dotenv()

with open("dump.json", "w") as f:
    redisdl.dump(
        f,
        host=os.getenv("REDIS_SOURCE_HOSTNAME", "localhost"),
        port=os.getenv("REDIS_SOURCE_PORT", 6379),
        password=os.getenv("REDIS_SOURCE_PASSWORD", "localhost"),
        db=os.getenv("REDIS_SOURCE_DB", 3),
    )
示例#14
0
# requires pip install redis-dump-load
import redisdl

json_text = redisdl.dumps()

with open('redis-dump.json', 'w') as f:
    redisdl.dump(f)
示例#15
0
def dump_redis_to_json():
    json_text = redisdl.dumps()

    with open('tmp/dump.json', 'w') as f:
        # streams data
        redisdl.dump(f)