Restore Module

pybacked.restore.find_diff(logfile, filename)

Find a diff-log occurance in a file. If one exists return the diff line. If the filename given is not found return 0.

Parameters
  • logfile – the csv log-file to be searched

  • filename – the name of the desired file

Returns

the diff-entry or None depending if filename was found

Return type

dict

pybacked.restore.find_diff_archive(archivepath, filename)

Find a diff-log occurance in an archive. If one exists return the diff line. If the filename given is not found return 0.

Parameters
  • archivepath – The path of the archive

  • filename – The name of the desired file

Returns

the diff-entry or None depending if filename was found

Return type

dict

pybacked.restore.get_arch_state(filename, archivedir, diff_algorithm)

Get the last (diff) state of the archived file version.

Parameters
  • filename (str) – The filename searched for

  • archivedir (str) – The directory where the archive files are stored

  • diff_algorithm (int) – The diff-detection algorithm used

Returns

the last state (diff) of the archived file

pybacked.restore.get_archive_list(archivedir)

Return a list of paths to all the backup archives.

Parameters

archivedir – The directory in which archives are stored

Returns

a list of paths to all the backup archives

Return type

list

pybacked.restore.get_current_state(filepath, diff_algorithm, hash_algorithm=None)

Get the current state of the file.

Parameters
  • filepath (str) – the path to the file

  • diff_algorithm (int) – the diff algorithm used

  • hash_algorithm (str, optional) – the desired hash algorithm

Returns

return the current state, or None if file doesn’t exist

pybacked.restore.get_edit_date(filepath)

Return the unix timestamp for the last edit. This function is primarily implemented for increasing readability.

Parameters

filepath – the filename

Returns

timestamp of the last edited date

Return type

float

pybacked.restore.get_file_content(filepath)

Get the file content in binary mode

Parameters

filepath (str) – The path to the file

Returns

The content of the file

Return type

bytes

pybacked.restore.get_file_hash(filepath, algorithm)

Get hash of a file.

Parameters
  • filepath (str) – the path to the file

  • algorithm (str) – the desired hashing algorithm

Returns

Hash of the file in hex form.

Return type

str

pybacked.restore.restore(config, archname, alt_dir=None)

Restore a given backup to the original source directory or an alternative directory.

Parameters
  • config (Configuration) – The configuration for the backup

  • archname (str) – The name of the archive which holds the state which should be restored.

  • alt_dir (str, optional) – Specifies an alternate directory in which the source will be restored. If this is None, the function will restore the source to the original source directory specified in the provieded Configuration class instance.

Returns

void

Return type

None

pybacked.restore.restore_archive_state(archive, restore_dir)

Restore a given archive state. This will restore the state of the source at the creation of the specified archive.

Parameters
  • archive (str) – The path to the specific zip-archive with the state that is to be restored

  • restore_dir (str) – The directory in which the archive should be restored

Returns

void

Return type

None