def deduplication_backup(self, process_bar):
self.fast_backup = False  <EOL>src_path = self.dir_path.resolved_path<EOL>log.debug("<STR_LIT>", src_path)<EOL>log.debug("<STR_LIT>", self.path_helper.abs_src_filepath)<EOL>log.debug("<STR_LIT>", self.path_helper.abs_dst_filepath)<EOL>log.debug("<STR_LIT>", self.path_helper.abs_dst_hash_filepath)<EOL>log.debug("<STR_LIT>", self.path_helper.abs_dst_path)<EOL>if not self.path_helper.abs_dst_path.is_dir():<EOL><INDENT>try:<EOL><INDENT>self.path_helper.abs_dst_path.makedirs(mode=phlb_config.default_new_path_mode)<EOL><DEDENT>except OSError as err:<EOL><INDENT>raise BackupFileError("<STR_LIT>" % err)<EOL><DEDENT><DEDENT>else:<EOL><INDENT>assert not self.path_helper.abs_dst_filepath.is_file(), (<EOL>"<STR_LIT>" % self.path_helper.abs_src_filepath<EOL>)<EOL><DEDENT>try:<EOL><INDENT>try:<EOL><INDENT>with self.path_helper.abs_src_filepath.open("<STR_LIT:rb>") as in_file:<EOL><INDENT>with self.path_helper.abs_dst_hash_filepath.open("<STR_LIT:w>") as hash_file:<EOL><INDENT>with self.path_helper.abs_dst_filepath.open("<STR_LIT:wb>") as out_file:<EOL><INDENT>hash = self._deduplication_backup(self.dir_path, in_file, out_file, process_bar)<EOL><DEDENT>hash_hexdigest = hash.hexdigest()<EOL>hash_file.write(hash_hexdigest)<EOL><DEDENT><DEDENT><DEDENT>except OSError as err:<EOL><INDENT>raise BackupFileError("<STR_LIT>" % (self.path_helper.abs_src_filepath, err))<EOL><DEDENT><DEDENT>except KeyboardInterrupt:<EOL><INDENT>try:<EOL><INDENT>self.path_helper.abs_dst_filepath.unlink()<EOL><DEDENT>except OSError:<EOL><INDENT>pass<EOL><DEDENT>try:<EOL><INDENT>self.path_helper.abs_dst_hash_filepath.unlink()<EOL><DEDENT>except OSError:<EOL><INDENT>pass<EOL><DEDENT>raise KeyboardInterrupt<EOL><DEDENT>old_backup_entry = deduplicate(self.path_helper.abs_dst_filepath, hash_hexdigest)<EOL>if old_backup_entry is None:<EOL><INDENT>log.debug("<STR_LIT>")<EOL>self.file_linked = False  <EOL><DEDENT>else:<EOL><INDENT>log.debug("<STR_LIT>" % old_backup_entry)<EOL>self.file_linked = True  <EOL><DEDENT>atime_ns = self.dir_path.stat.st_atime_ns<EOL>mtime_ns = self.dir_path.stat.st_mtime_ns<EOL>self.path_helper.abs_dst_filepath.utime(ns=(atime_ns, mtime_ns))  <EOL>log.debug("<STR_LIT>" % mtime_ns)<EOL>BackupEntry.objects.create(<EOL>backup_run=self.backup_run,<EOL>backup_entry_path=self.path_helper.abs_dst_filepath,<EOL>hash_hexdigest=hash_hexdigest,<EOL>)<EOL>self.fast_backup = False<EOL>
Backup the current file and compare the content.

:param process_bar: tqdm process bar