def _i_cannot_see_the_backup_named_backupname_when_i_list_the_backups(context, backup_name): storage = Storage(config=context.medusa_config.storage) cluster_backups = storage.list_cluster_backups() found = False for backup in cluster_backups: if backup.name == backup_name: found = True assert found is False
def get_backups(config, show_all): storage = Storage(config=config.storage) cluster_backups = sorted(storage.list_cluster_backups(), key=lambda b: b.started) if not show_all: cluster_backups = filter( lambda cluster_backup: config.storage.fqdn in cluster_backup. node_backups, cluster_backups) return cluster_backups
def delete_backup(config, backup_names, all_nodes): monitoring = Monitoring(config=config.monitoring) try: storage = Storage(config=config.storage) cluster_backups = storage.list_cluster_backups() backups_to_purge = backups_to_purge_by_name(storage, cluster_backups, backup_names, all_nodes) logging.info('Deleting Backup(s) {}...'.format(",".join(backup_names))) purge_backups(storage, backups_to_purge, config.storage.backup_grace_period_in_days, storage.config.fqdn) logging.debug('Emitting metrics') tags = ['medusa-node-backup', 'delete-error', 'DELETE-ERROR'] monitoring.send(tags, 0) except Exception as e: tags = ['medusa-node-backup', 'delete-error', 'DELETE-ERROR'] monitoring.send(tags, 1) medusa.utils.handle_exception( e, 'This error happened during the delete of backup(s) "{}": {}'. format(",".join(backup_names), str(e)), config)
def _i_can_see_no_backups(context): storage = Storage(config=context.medusa_config.storage) cluster_backups = storage.list_cluster_backups() assert 0 == len(list(cluster_backups))