twindb_backup.status package

Submodules

twindb_backup.status.base_status module

Base status is a class for a general purpose status.

class twindb_backup.status.base_status.BaseStatus(content=None, dst=None, status_directory=None)[source]

Bases: object

Base class for status. It can be instantiated either from a string with status content or from a destination instance. If the destination is given then the status will be read from a status file on the destination.

Parameters:
  • content (str) – if passed it will initialize a status from this string.
  • dst (BaseDestination) – Destination instance.
  • status_directory (str) – Relative path to a directory where the status file is stored. Usually, it’s a hostname where backup was taken from.
Raises:

CorruptedStatus – If the content string is not a valid status or empty string.

add(backup_copy)[source]

Add entry to status.

Parameters:backup_copy (BaseCopy) – Instance of backup copy
basename

Returns file name without a directory path where the status is stored in the destination.

latest_backup

Find the latest backup copy.

Returns:backup copy or None if status is empty.
Return type:BaseCopy
md5
Returns:MD5 checksum of the status. It is calculated as a md5 of output of self._status_serialize().
Return type:str
remove(key)[source]

Remove key from the status.

Parameters:key (str) – A copy key in the status.
save(dst)[source]

Write status file to the destination.

Parameters:dst (BasicDestination) – Destination instance.
serialize()[source]

Return a string that represents current state

status_path

Return relative path where status is stored.

Returns:relative to the destination path where the status is stored.
Return type:str
version

Version of status file. Originally status file didn’t have any versions, but in future the version will be used to work with new features.

twindb_backup.status.exceptions module

Status exceptions

exception twindb_backup.status.exceptions.CorruptedStatus[source]

Bases: twindb_backup.status.exceptions.StatusError

Status file is corrupt

exception twindb_backup.status.exceptions.StatusError[source]

Bases: twindb_backup.exceptions.TwinDBBackupError

General status error

exception twindb_backup.status.exceptions.StatusKeyNotFound[source]

Bases: twindb_backup.status.exceptions.StatusError

Accessing a key that doesn’t exist

twindb_backup.status.mysql_status module

Class to store and work with status file

class twindb_backup.status.mysql_status.MySQLStatus(content=None, dst=None, status_directory=None)[source]

Bases: twindb_backup.status.periodic_status.PeriodicStatus

Class that stores status file and implements operations on it.

basename
candidate_parent(run_type)[source]

Find a backup copy that can be a parent

Parameters:run_type – See get_backup_type().
Returns:Backup copy or None
Return type:MySQLCopy
full_copy_exists(run_type)[source]

Check whether there is a full copy.

Parameters:run_type – See get_backup_type().
Returns:True if there is a full copy. False if there is no an eligible full copy.
Return type:bool
next_backup_type(full_backup, run_type)[source]

Return backup type to take. If full_backup=daily then for hourly backups it will be incremental, for all other - full

Parameters:
  • full_backup – when to take full backup according to config.
  • run_type – what kind of backup run it is.
Returns:

“full” or “incremental”

Return type:

str

Module contents