Skip to content

Commit

Permalink
up
Browse files Browse the repository at this point in the history
  • Loading branch information
tksmly committed May 8, 2023
1 parent f0ee4d2 commit a3e6c4b
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,12 @@ mcd_root/

是否在备份时临时关闭自动保存

### copy_on_write

默认值: `false`

使用某些文件系统的写时拷贝(一种增量备份)

### ignored_files

默认值:
Expand Down
6 changes: 6 additions & 0 deletions README_en.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,12 @@ Default: `true`

If turn off auto save when making backup or not

### copy_on_write

Default: `false`

Useing copy_on_write in some File system(incremental backup)

### ignored_files

If ignore file `session.lock` during backup, which can
Expand Down
10 changes: 5 additions & 5 deletions quick_backup_multi/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@ def get_backup_file_name(backup_format: BackupFormat):


copy_file_range_supported=hasattr(os, "copy_file_range")
COW_COPY_LIMIT = 2**30 # 1GB / need int, may overflow, so cannot copy files larger than 2GB in a single pass
COW_COPY_BUFFER_SIZE = 2**30 # 1GB / need int, may overflow, so cannot copy files larger than 2GB in a single pass

#copy using "Copy On Write"
def _cpcow(src_path: str, dst_path: str):
if not copy_file_range_supported or not config.copy_on_write:
Expand All @@ -88,15 +89,14 @@ def _cpcow(src_path: str, dst_path: str):

try:
with open(src_path,'rb') as fsrc, open(dst_path,'wb+') as fdst:
while os.copy_file_range(fsrc.fileno(), fdst.fileno(), COW_COPY_LIMIT):
while os.copy_file_range(fsrc.fileno(), fdst.fileno(), COW_COPY_BUFFER_SIZE):
pass


except Exception as e:
server_inst.logger.warning(str(e) + '({} -> {})'.format(src_path, src_path, dst_path) + ",Retry with other functions")
server_inst.logger.warning(str(e) + str(src_path) + "->" + str(dst_path) + ",Retry with other functions")
shutil.copy(src_path, dst_path)

shutil.copystat(src_path, dst_path) # copy2
shutil.copystat(src_path, dst_path) # copy2
return dst_path


Expand Down

0 comments on commit a3e6c4b

Please sign in to comment.