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

abstract property basename

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

property latest_backup

Find the latest backup copy.

Returns

backup copy or None if status is empty.

Return type

BaseCopy

property 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

property status_path

Return relative path where status is stored.

Returns

relative to the destination path where the status is stored.

Return type

str

property 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.binlog_status module

Binlog status is a class for a binlog copies status.

class twindb_backup.status.binlog_status.BinlogStatus(content=None, dst=None, status_directory=None)[source]

Bases: twindb_backup.status.base_status.BaseStatus

Binlog class for status

property basename

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

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.

property basename

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

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

twindb_backup.status.periodic_status module

Periodic status is a class for a periodic copies status. For now status is created/maintained for MySQL copies only.

class twindb_backup.status.periodic_status.PeriodicStatus(content=None, dst=None, status_directory=None)[source]

Bases: twindb_backup.status.base_status.BaseStatus

Periodic class for status.

property basename

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

property daily

Dictionary with daily backups

property hourly

Dictionary with hourly backups

property monthly

Dictionary with monthly backups

property weekly

Dictionary with weekly backups

property yearly

Dictionary with yearly backups

Module contents