barman.annotations module#

class barman.annotations.AnnotationManagerView on GitHub#

Bases: object

This abstract base class defines the AnnotationManager interface which provides methods for read, write and delete of annotations for a given backup.

_abc_impl = <_abc._abc_data object>#
abstract delete_annotation(backup_id, key)View on GitHub#

Delete an annotation

abstract get_annotation(backup_id, key)View on GitHub#

Get the value of an annotation

abstract put_annotation(backup_id, key, value)View on GitHub#

Add an annotation

class barman.annotations.AnnotationManagerCloud(cloud_interface, server_name)View on GitHub#

Bases: AnnotationManager

__init__(cloud_interface, server_name)View on GitHub#

Constructor for the cloud-based annotation manager. Should be initialised with the CloudInterface and name of the server which was used to create the backups.

_abc_impl = <_abc._abc_data object>#
_get_annotation_path(backup_id, key)View on GitHub#

Builds the full key to the annotation in cloud storage for the specified backup_id and annotation key.

_get_base_path()View on GitHub#

Returns the base path to the cloud storage, accounting for the fact that CloudInterface.path may be None.

_populate_annotation_cache()View on GitHub#

Build a cache of which annotations actually exist by walking the bucket. This allows us to optimize get_annotation by just checking a (backup_id,key) tuple here which is cheaper (in time and money) than going to the cloud every time.

delete_annotation(backup_id, key)View on GitHub#

Deletes an annotation from cloud storage for the specified backup_id and annotation key.

get_annotation(backup_id, key, use_cache=True)View on GitHub#

Reads the annotation key for the specified backup_id from cloud storage and returns the value.

The default behaviour is that, when it is first run, it populates a cache of the annotations which exist for each backup by walking the bucket. Subsequent operations can check that cache and avoid having to call remote_open if an annotation is not found in the cache.

This optimises for the case where annotations are sparse and assumes the cost of walking the bucket is less than the cost of the remote_open calls which would not return a value.

In cases where we do not want to walk the bucket up front then the caching can be disabled.

put_annotation(backup_id, key, value)View on GitHub#

Writes the specified value for annotation key for the specified backup_id to cloud storage.

class barman.annotations.AnnotationManagerFile(path)View on GitHub#

Bases: AnnotationManager

__init__(path)View on GitHub#

Constructor for the file-based annotation manager. Should be initialised with the path to the barman base backup directory.

_abc_impl = <_abc._abc_data object>#
_get_annotation_path(backup_id, key)View on GitHub#

Builds the annotation path for the specified backup_id and annotation key.

delete_annotation(backup_id, key)View on GitHub#

Deletes an annotation from the filesystem for the specified backup_id and annotation key.

get_annotation(backup_id, key)View on GitHub#

Reads the annotation key for the specified backup_id from the filesystem and returns the value.

put_annotation(backup_id, key, value)View on GitHub#

Writes the specified value for annotation key for the specified backup_id to the filesystem.

class barman.annotations.KeepManagerView on GitHub#

Bases: object

Abstract base class which defines the KeepManager interface

ANNOTATION_KEY = 'keep'#
TARGET_FULL = 'full'#
TARGET_STANDALONE = 'standalone'#
_abc_impl = <_abc._abc_data object>#
abstract get_keep_target(backup_id)View on GitHub#
abstract keep_backup(backup_id, target)View on GitHub#
abstract release_keep(backup_id)View on GitHub#
abstract should_keep_backup(backup_id)View on GitHub#
supported_targets = ('full', 'standalone')#
class barman.annotations.KeepManagerMixin(*args, **kwargs)View on GitHub#

Bases: KeepManager

A Mixin which adds KeepManager functionality to its subclasses.

Keep management is built on top of annotations and consists of the following functionality:

  • Determine whether a given backup is intended to be kept beyond its retention period.

  • Determine the intended recovery target for the archival backup.

  • Add and remove the keep annotation.

The functionality is implemented as a Mixin so that it can be used to add keep management to the backup management class in barman (BackupManager) as well as its closest analog in barman-cloud (CloudBackupCatalog).

__init__(*args, **kwargs)View on GitHub#

Base constructor (Mixin pattern).

kwargs must contain either:
  • A barman.server.Server object with the key server, or:

  • A CloudInterface object and a server name, keys cloud_interface and server_name respectively.

_abc_impl = <_abc._abc_data object>#
get_keep_target(backup_id)View on GitHub#

Retrieve the intended recovery target

keep_backup(backup_id, target)View on GitHub#

Add a keep annotation for backup with ID backup_id with the specified recovery target.

release_keep(backup_id)View on GitHub#

Release the keep annotation

should_keep_backup(backup_id)View on GitHub#

Returns True if the specified backup_id for this server has a keep annotation. False otherwise.

class barman.annotations.KeepManagerMixinCloud(*args, **kwargs)View on GitHub#

Bases: KeepManagerMixin

A specialised KeepManager which allows the annotation caching optimization in the AnnotationManagerCloud backend to be optionally disabled.

_abc_impl = <_abc._abc_data object>#
get_keep_target(backup_id, use_cache=True)View on GitHub#

Like KeepManagerMixinCloud.get_keep_target but with the use_cache option.

should_keep_backup(backup_id, use_cache=True)View on GitHub#

Like KeepManagerMixinCloud.should_keep_backup but with the use_cache option.