The freezer.engine.rsync.rsync Module

Freezer rsync incremental engine

Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

class freezer.engine.rsync.rsync.RsyncEngine(compression, symlinks, exclude, storage, max_segment_size, encrypt_key=None, dry_run=False)[source]

Bases: freezer.engine.engine.BackupEngine

backup_data(backup_path, manifest_path)[source]

Execute backup using rsync algorithm.

If an existing rsync meta data is available the backup will be incremental, otherwise will be executed a level 0 backup

Parameters:
  • backup_path
  • manifest_path
Returns:

static compute_checksums(rel_path, files_meta, reg_file=True)[source]
compute_incrementals(rel_path, inode_str_struct, inode_dict_struct, files_meta, old_fs_meta_struct, write_queue, deleted=False)[source]
static gen_file_header(file_path, inode_str_struct)[source]

Generate file header for rsync binary data file

Parameters:
  • file_path – file path
  • inode_str_struct – file binary string including inode data
Returns:

chunk of binary data to be processed on the next iteration

gen_struct_for_deleted_files(files_meta, old_fs_meta_struct, rel_path, write_queue)[source]
get_file_struct(fs_path, new_level=False)[source]

Generate file meta data from file abs path.

Return the meta data as a dict structure and a binary string

Parameters:fs_path – file abs path

:param new_level :return: file data structure

static get_file_type(file_mode, fs_path)[source]

Extract file type from the the file mode retrieved from file abs path

Parameters:
  • file_mode
  • fs_path
Returns:

get_fs_meta_struct(fs_meta_path)[source]
static get_old_file_meta(old_fs_meta_struct, rel_path)[source]
get_sign_delta(fs_path, manifest_path, write_queue)[source]

Compute the file or fs tree path signatures.

Parameters:fs_path

:param manifest_path :param write_queue: :return:

static is_file_modified(old_file_meta, file_meta)[source]

Check for changes on inode or file data

Parameters:
  • old_file_meta – meta data of the previous backup execution
  • file_meta – meta data of the current backup execution
Returns:

True if the file changed, False otherwise

static is_reg_file(file_type)[source]
make_files(header_list, restore_abs_path, read_pipe, data_chunk, flushed, current_backup_level)[source]

Header list binary structure:

header_len, file_abs_path, RSYNC_DATA_STRUCT_VERSION, file_mode, os_stat.st_uid, os_stat.st_gid, os_stat.st_size, mtime, ctime, uname, gname, file_type, linkname, rsync_block_size,

Parameters:
  • header_list
  • restore_abs_path
  • read_pipe
  • data_chunk
  • flushed
  • current_backup_level
Returns:

make_reg_file(size, file_path, read_pipe, data_chunk, flushed, level_id)[source]

Create the regular file and write data on it.

Parameters:
  • size
  • file_path
  • read_pipe
  • data_chunk
  • flushed
  • level_id
Returns:

metadata()[source]
name
process_backup_data(data, do_compress=True)[source]

Compresses and encrypts provided data according to args

process_file(file_path, fs_path, files_meta, old_fs_meta_struct, write_queue)[source]
process_restore_data(data)[source]

Decrypts and decompresses provided data according to args

restore_level(restore_path, read_pipe, backup, except_queue)[source]

Restore the provided file into restore_abs_path.

Decrypt the file if backup_opt_dict.encrypt_pass_file key is provided. Freezer rsync header data structure:

header_len, RSYNC_DATA_STRUCT_VERSION, file_mode, os_stat.st_uid, os_stat.st_gid, os_stat.st_size, mtime, ctime, uname, gname, file_type, linkname
Parameters:
  • restore_path
  • read_pipe
  • backup
  • except_queue
Returns:

static rsync_gen_delta(file_path_fd, old_file_meta)[source]

Get rsync delta for file descriptor provided as arg.

Parameters:
  • file_path_fd
  • old_file_meta
Returns:

set_inode(uname, gname, mtime, name)[source]

Set the file inode fields according to the provided args.

Parameters:
  • uname
  • gname
  • mtime
  • name
Returns:

write_changes_in_file(fd_curr_file, data_chunk, read_pipe)[source]
write_file(file_fd, size, data_chunk, read_pipe, flushed)[source]