1
This commit is contained in:
parent
dba6777766
commit
3d5d2b8c89
@ -60,7 +60,10 @@ def saveKeys(r, keys, curr_file):
|
|||||||
print('[ERROR] ' + key + ' ttl > 3600 * 24')
|
print('[ERROR] ' + key + ' ttl > 3600 * 24')
|
||||||
|
|
||||||
def exportRedis(context, redis_conf, redis_rule_conf):
|
def exportRedis(context, redis_conf, redis_rule_conf):
|
||||||
curr_file = open(context['out_dir'] + context['channel'] + '.redis', 'w')
|
redis_dir = CONFIG_DIR + 'out/' + context['channel'] + '/redis/'
|
||||||
|
if not os.path.exists(redis_dir):
|
||||||
|
os.mkdir(redis_dir)
|
||||||
|
curr_file = open(redis_dir + context['channel'] + '.redis', 'w')
|
||||||
for conf in redis_conf:
|
for conf in redis_conf:
|
||||||
r = redis.Redis(host = conf['host'],
|
r = redis.Redis(host = conf['host'],
|
||||||
port = conf['port'],
|
port = conf['port'],
|
||||||
@ -74,22 +77,26 @@ def exportRedis(context, redis_conf, redis_rule_conf):
|
|||||||
#end for conf
|
#end for conf
|
||||||
|
|
||||||
def exportMysql(context, db_conf, db_rule_conf):
|
def exportMysql(context, db_conf, db_rule_conf):
|
||||||
dbsh_file = open(context['out_dir'] + context['channel'] + '.sh', 'w')
|
dbsh_file = open(context['out_dir'] + 'exportdb.sh', 'w')
|
||||||
for conf in db_conf:
|
for conf in db_conf:
|
||||||
|
db_dir = CONFIG_DIR + 'out/' + context['channel'] + '/' + str(conf['instance_id'])
|
||||||
|
if not os.path.exists(db_dir):
|
||||||
|
os.mkdir(db_dir)
|
||||||
for rule in db_rule_conf:
|
for rule in db_rule_conf:
|
||||||
line = ''
|
line = ''
|
||||||
if rule['where'] == '':
|
if rule['where'] == '':
|
||||||
line = 'mysqldump -h %s -P %d -u%s -p%s %s %s > %s.sql' % (
|
line = 'mysqldump -h %s -P %d -u%s -p%s %s %s > %d/%s.sql' % (
|
||||||
conf['host'],
|
conf['host'],
|
||||||
conf['port'],
|
conf['port'],
|
||||||
conf['user'],
|
conf['user'],
|
||||||
conf['passwd'],
|
conf['passwd'],
|
||||||
context['dbname_prefix'] + str(conf['instance_id']),
|
context['dbname_prefix'] + str(conf['instance_id']),
|
||||||
rule['table_name'],
|
rule['table_name'],
|
||||||
|
conf['instance_id'],
|
||||||
rule['table_name']
|
rule['table_name']
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
line = 'mysqldump -h %s -P %d -u%s -p%s %s %s --where="%s"> %s.sql' % (
|
line = 'mysqldump -h %s -P %d -u%s -p%s %s %s --where="%s"> %d/%s.sql' % (
|
||||||
conf['host'],
|
conf['host'],
|
||||||
conf['port'],
|
conf['port'],
|
||||||
conf['user'],
|
conf['user'],
|
||||||
@ -97,6 +104,7 @@ def exportMysql(context, db_conf, db_rule_conf):
|
|||||||
context['dbname_prefix'] + str(conf['instance_id']),
|
context['dbname_prefix'] + str(conf['instance_id']),
|
||||||
rule['table_name'],
|
rule['table_name'],
|
||||||
rule['where'].replace('$channel', context['channel']),
|
rule['where'].replace('$channel', context['channel']),
|
||||||
|
conf['instance_id'],
|
||||||
rule['table_name']
|
rule['table_name']
|
||||||
)
|
)
|
||||||
dbsh_file.write(line + "\n")
|
dbsh_file.write(line + "\n")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user