duplicity.dup_collections module

Classes and functions on collections of backup volumes

class duplicity.dup_collections.BackupChain(backend)[source]

Bases: object

BackupChain - a number of linked BackupSets

A BackupChain always starts with a full backup set and continues with incremental ones.

__init__(backend)[source]

Initialize new chain, only backend is required at first

add_inc(incset)[source]

Add incset to self. Return False if incset does not match

delete(keep_full=False)[source]

Delete all sets in chain, in reverse order

get_all_sets()[source]

Return list of all backup sets in chain

get_first()[source]

Return first BackupSet in chain (ie the full backup)

get_last()[source]

Return last BackupSet in chain

get_num_volumes()[source]

Return the total number of volumes in the chain

get_sets_at_time(time)[source]

Return a list of sets in chain earlier or equal to time

set_full(fullset)[source]

Add full backup set

short_desc()[source]

Return a short one-line description of the chain, suitable for log messages.

to_log_info(prefix='')[source]

Return summary, suitable for printing to log

class duplicity.dup_collections.BackupSet(backend, action)[source]

Bases: object

Backup set - the backup information produced by one session

__init__(backend, action)[source]

Initialize new backup set, only backend is required at first

add_filename(filename, pr=None)[source]

Add a filename to given set. Return true if it fits.

The filename will match the given set if it has the right times and is of the right type. The information will be set from the first filename given.

@param filename: name of file to add @type filename: string

@param pr: pre-computed result of file_naming.parse(filename) @type pr: Optional[ParseResults]

check_manifests(check_remote=True)[source]

Make sure remote manifest is equal to local one

delete()[source]

Remove all files in set, both local and remote

get_filenames()[source]

Return sorted list of (remote) filenames of files in set

get_files_changed()[source]
get_local_manifest()[source]

Return manifest object by reading local manifest file

get_manifest()[source]

Return manifest object, showing preference for local copy

get_remote_manifest()[source]

Return manifest by reading remote manifest on backend

get_time()[source]

Return time if full backup, or end_time if incremental

get_timestr()[source]

Return time string suitable for log statements

is_complete()[source]

Assume complete if found manifest file

set_files_changed()[source]
set_info(pr)[source]

Set BackupSet information from ParseResults object

@param pr: parse results @type pf: ParseResults

set_manifest(remote_filename)[source]

Add local and remote manifest filenames to backup set

class duplicity.dup_collections.BackupSetChangesStatus(backup_set)[source]

Bases: object

__init__(backup_set)[source]
exception duplicity.dup_collections.CollectionsError[source]

Bases: Exception

class duplicity.dup_collections.CollectionsStatus(backend, archive_dir_path, action)[source]

Bases: object

Hold information about available chains and sets

__init__(backend, archive_dir_path, action)[source]

Make new object. Does not set values

get_all_file_changed_records(set_index)[source]

Returns file changes in the specific backup set

get_backup_chain_at_time(time)[source]

Return backup chain covering specified time

Tries to find the backup chain covering the given time. If there is none, return the earliest chain before, and failing that, the earliest chain.

get_backup_chains(filename_list)[source]

Split given filename_list into chains

Return value will be tuple (list of chains, list of sets, list of incomplete sets), where the list of sets will comprise sets not fitting into any chain, and the incomplete sets are sets missing files.

get_chains_older_than(t)[source]

Returns a list of backup chains older than the given time t

All of the times will be associated with an intact chain. Furthermore, none of the times will be of a chain which a newer set may depend on. For instance, if set A is a full set older than t, and set B is an incremental based on A which is newer than t, then the time of set A will not be returned.

get_extraneous()[source]

Return list of the names of extraneous duplicity files

A duplicity file is considered extraneous if it is recognizable as a duplicity file, but isn’t part of some complete backup set, or current signature chain.

get_file_changed_record(filepath)[source]

Returns time line of specified file changed

get_last_backup_chain()[source]

Return the last full backup of the collection, or None if there is no full backup chain.

get_last_full_backup_time()[source]

Return the time of the last full backup, or 0 if there is none.

get_nth_last_backup_chain(n)[source]

Return the nth-to-last full backup of the collection, or None if there is less than n backup chains.

NOTE: n = 1 -> time of latest available chain (n = 0 is not a valid input). Thus the second-to-last is obtained with n=2 rather than n=1.

get_nth_last_full_backup_time(n)[source]

Return the time of the nth to last full backup, or 0 if there is none.

get_older_than(t)[source]

Returns a list of backup sets older than the given time t

All of the times will be associated with an intact chain. Furthermore, none of the times will be of a set which a newer set may depend on. For instance, if set A is a full set older than t, and set B is an incremental based on A which is newer than t, then the time of set A will not be returned.

get_older_than_required(t)[source]

Returns list of old backup sets required by new sets

This function is similar to the previous one, but it only returns the times of sets which are old but part of the chains where the newer end of the chain is newer than t.

get_signature_chain_at_time(time)[source]

Return signature chain covering specified time

Tries to find the signature chain covering the given time. If there is none, return the earliest chain before, and failing that, the earliest chain.

get_signature_chains(local, filelist=None)[source]

Find chains in archive_dir_path (if local is true) or backend

Use filelist if given, otherwise regenerate. Return value is pair (list of chains, list of signature paths not in any chains).

get_signature_chains_older_than(t)[source]

Returns a list of signature chains older than the given time t

All of the times will be associated with an intact chain. Furthermore, none of the times will be of a chain which a newer set may depend on. For instance, if set A is a full set older than t, and set B is an incremental based on A which is newer than t, then the time of set A will not be returned.

get_sorted_chains(chain_list)[source]

Return chains sorted by end_time. If tie, local goes last

get_sorted_sets(set_list)[source]

Sort set list by end time, return (sorted list, incomplete)

set_matched_chain_pair(sig_chains, backup_chains)[source]

Set self.matched_chain_pair and self.other_sig/backup_chains

The latest matched_chain_pair will be set. If there are both remote and local signature chains capable of matching the latest backup chain, use the local sig chain (it does not need to be downloaded).

set_values(sig_chain_warning=1)[source]

Set values from archive_dir_path and backend.

Returns self for convenience. If sig_chain_warning is set to None, do not warn about unnecessary sig chains. This is because there may naturally be some unecessary ones after a full backup.

sort_sets(setlist)[source]

Return new list containing same elems of setlist, sorted by time

to_log_info()[source]

Return summary of the collection, suitable for printing to log

warn(sig_chain_warning)[source]

Log various error messages if find incomplete/orphaned files

class duplicity.dup_collections.FileChangedStatus(filepath, fileinfo_list)[source]

Bases: object

__init__(filepath, fileinfo_list)[source]
class duplicity.dup_collections.SignatureChain(local, location)[source]

Bases: object

A number of linked SignatureSets

Analog to BackupChain - start with a full-sig, and continue with new-sigs.

__init__(local, location)[source]

Return new SignatureChain.

local should be true iff the signature chain resides in config.archive_dir_path and false if the chain is in config.backend.

@param local: True if sig chain in config.archive_dir_path @type local: Boolean

@param location: Where the sig chain is located @type location: config.archive_dir_path or config.backend

add_filename(filename, pr=None)[source]

Add new sig filename to current chain. Return true if fits

check_times(time_list)[source]

Check to make sure times are in whole seconds

delete(keep_full=False)[source]

Remove all files in signature set

get_filenames(time=None)[source]

Return ordered list of filenames in set, up to a provided time

get_fileobjs(time=None)[source]

Return ordered list of signature fileobjs opened for reading, optionally at a certain time

islocal()[source]

Return true if represents a signature chain in archive_dir_path