duplicity.backend module

Provides a common interface to all backends and certain sevices intended to be used by the backends themselves.

class duplicity.backend.Backend(parsed_url)[source]

Bases: object

See README in backends directory for information on how to write a backend.

__init__(parsed_url)[source]
__subprocess_popen(args)

For internal use. Execute the given command line, interpreted as a shell command. Returns int Exitcode, string StdOut, string StdErr

get_password()[source]

Return a password for authentication purposes. The password will be obtained from the backend URL, the environment, by asking the user, or by some other method. When applicable, the result will be cached for future invocations.

munge_password(commandline)[source]

Remove password from commandline by substituting the password found in the URL, if any, with a generic place-holder.

This is intended for display purposes only, and it is not guaranteed that the results are correct (i.e., more than just the ‘:password@’ may be substituted.

popen_breaks = {}
subprocess_popen(commandline)[source]

Execute the given command line with error check. Returns int Exitcode, string StdOut, string StdErr

Raise a BackendException on failure.

use_getpass = True
class duplicity.backend.BackendWrapper(backend)[source]

Bases: object

Represents a generic duplicity backend, capable of storing and retrieving files.

__do_put(source_path, remote_filename)
__init__(backend)[source]
_do_delete(*args)[source]
_do_delete_list(*args)[source]
_do_query(*args)[source]
_do_query_list(*args)[source]
close()[source]

Close the backend, releasing any resources held and invalidating any file objects obtained from the backend.

delete(filename_list)[source]

Delete each filename in filename_list, in order if possible.

get(*args)[source]
get_data(filename, parseresults=None)[source]

Retrieve a file from backend, process it, return contents.

get_fileobj_read(filename, parseresults=None)[source]

Return fileobject opened for reading of filename on backend

The file will be downloaded first into a temp file. When the returned fileobj is closed, the temp file will be deleted.

list(*args)[source]
move(*args)[source]
pre_process_download(remote_filename)[source]

Manages remote access before downloading files (unseal data in cold storage for instance)

pre_process_download_batch(remote_filenames)[source]

Manages remote access before downloading files (unseal data in cold storage for instance)

put(*args)[source]
query_info(filename_list)[source]

Return metadata about each filename in filename_list

class duplicity.backend.ParsedUrl(url_string)[source]

Bases: object

Parse the given URL as a duplicity backend URL.

Returns the data of a parsed URL with the same names as that of the standard urlparse.urlparse() except that all values have been resolved rather than deferred. There are no get_* members. This makes sure that the URL parsing errors are detected early.

Raise InvalidBackendURL on invalid URL’s

__init__(url_string)[source]
geturl()[source]
strip_auth()[source]
duplicity.backend._get_code_from_exception(backend, operation, e)[source]
duplicity.backend.get_backend(url_string)[source]

Instantiate a backend suitable for the given URL, or return None if the given string looks like a local path rather than a URL.

Raise InvalidBackendURL if the URL is not a valid URL.

duplicity.backend.get_backend_object(url_string)[source]

Find the right backend class instance for the given URL, or return None if the given string looks like a local path rather than a URL.

Raise InvalidBackendURL if the URL is not a valid URL.

duplicity.backend.import_backends()[source]

Import files in the duplicity/backends directory where the filename ends in ‘backend.py’ and ignore the rest.

@rtype: void @return: void

duplicity.backend.is_backend_url(url_string)[source]

@return Whether the given string looks like a backend URL.

duplicity.backend.register_backend(scheme, backend_factory)[source]

Register a given backend factory responsible for URL:s with the given scheme.

The backend must be a callable which, when called with a URL as the single parameter, returns an object implementing the backend protocol (i.e., a subclass of Backend).

Typically the callable will be the Backend subclass itself.

This function is not thread-safe and is intended to be called during module importation or start-up.

duplicity.backend.register_backend_prefix(scheme, backend_factory)[source]

Register a given backend factory responsible for URL:s with the given scheme prefix.

The backend must be a callable which, when called with a URL as the single parameter, returns an object implementing the backend protocol (i.e., a subclass of Backend).

Typically the callable will be the Backend subclass itself.

This function is not thread-safe and is intended to be called during module importation or start-up.

duplicity.backend.retry(operation, fatal=True)[source]
duplicity.backend.strip_auth_from_url(parsed_url)[source]

Return a URL from a urlparse object without a username or password.

duplicity.backend.strip_prefix(url_string, prefix_scheme)[source]

strip the prefix from a string e.g. par2+ftp://… -> ftp://…