Skip to content

add check backup files before restore#8

Open
breakwang wants to merge 1 commit intomasterfrom
bk.refine-mysqlbackup
Open

add check backup files before restore#8
breakwang wants to merge 1 commit intomasterfrom
bk.refine-mysqlbackup

Conversation

@breakwang
Copy link
Contributor

see #6

@drmingdrmer
Copy link
Contributor

squash的pykit不放pr里吧...直接推到master应该没问题

@drmingdrmer
Copy link
Contributor

代码格式整理带来的差异有点多...等你弄完了我整理下再看.

GB = 1024**3

config = TransferConfig(multipart_threshold=1 * GB,
multipart_chunksize=512 * MB, )
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

multipart_chunksize 由原来的256MB 改成了 512MB
原因:之前发生过备份备份文件失败的情况,经过排查,发现是由于备份文件大,导致分配数量超过了限制。所以先将分片大小调大一些

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

˙º˙

@@ -20,21 +20,17 @@
import sys
import time
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个文件,基本上就是把boto相关的操作替换成了botoclient类。然后用pyauto整理了一下格式

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

恩...我看出来了...就是...现在代码不改了吧? 如果不改了我重新整理下, 然后需要强推下你这个分支.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

我来吧,我先把pykit 推到master 上,已经推完了,然后把格式整理和我改的代码分成两个提交点

@breakwang breakwang force-pushed the bk.refine-mysqlbackup branch from 264b1e0 to d4b51ad Compare November 19, 2018 07:01
mysqlops.py Outdated
for port in ports:
jm.put(port)

jm.join()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

join需要在循环外面...


for port in ports:
jm.put(port)
check_backup_file(ports)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if和else里都有check_backup_file?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if 的时候是单独只检查备份文件, else 的时候是 执行恢复的时候也默认检查一下

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

如果都检查的话, 应该放在if之前会比较合理...

mysqlops.py Outdated
jm = jobq.JobManager([(worker, args.jobs),
(output, 1)])
if cmd == 'check_backup_file':
check_backup_file(ports)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cmd的处理为啥不跟上面的一组ifel...放一起?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个函数的参数是所有端口ports,不需要放到jobq里去处理

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

所有ports跟正常流程走一样的逻辑比较好, 允许筛选.

命令行上不指定ports就是全部的. 偶尔可能还有需要只检查几个ports的需要

Copy link
Contributor Author

@breakwang breakwang Nov 20, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

嗯嗯,可能我表述有误,这个函数的参数是所有端口ports,不需要放到jobq里去处理
这里的所有端口是指--port 参数给定的端口
我这里的逻辑是,恢复--port参数给定的端口之前,先全检查一遍,或者支持使用--check_backup_file 只检查指定的端口操作, 这么可以避免某个端口失败导致整个恢复流程失败。

setdef(conf, 'clean_after_restore', args.clean_after_restore)

conf.setdefault('date_str', date_str)
setdef(conf, 'date_str', args.date_str)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

为啥有啥用setdef, 有时用dict.setdefault?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这块逻辑是从原来的主函数里拎出的
dict.setdefault 是为了给date_str 默认赋值
setdef 是更新操作

def setdef(dic, key, v):
    if v is not None:
        dic[key] = v

@breakwang breakwang force-pushed the bk.refine-mysqlbackup branch from d4b51ad to 9335afc Compare December 3, 2018 06:51
@breakwang breakwang force-pushed the bk.refine-mysqlbackup branch 2 times, most recently from 17de34c to 18c94a3 Compare December 17, 2018 09:50
@breakwang breakwang requested review from drmingdrmer and removed request for drmingdrmer March 31, 2019 15:22
@breakwang breakwang force-pushed the bk.refine-mysqlbackup branch from 18c94a3 to 580cc95 Compare December 23, 2019 08:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

Comments