bundlewrap/bundles/backup-server/metadata.py
Franziska Kunsmann 2d42e5f7dd
All checks were successful
bundlewrap/pipeline/head This commit looks good
update bw to 4.3, add .provides() to metadata reactors
2021-01-07 18:44:38 +01:00

59 lines
1.3 KiB
Python

defaults = {
'openssh': {
'allowed_users': {
# Usernames for backup clients always start with 'c-'
'c-*',
},
},
}
@metadata_reactor.provides(
'backup-server/clients',
)
def get_my_clients(metadata):
my_clients = {}
for rnode in repo.nodes:
if rnode.metadata.get('backups/exclude_from_backups', False) or rnode.dummy:
continue
my_clients[rnode.name] = {
'user': rnode.metadata.get('backup-client/user-name'),
}
return {
'backup-server': {
'clients': my_clients,
},
}
@metadata_reactor.provides(
'zfs/datasets',
'zfs/snapshots/retain_per_dataset',
)
def zfs(metadata):
zfs_datasets = {}
zfs_retains = {}
retain_defaults = {
'weekly': 4,
'monthly': 6,
}
for client in metadata.get('backup-server/clients', {}).keys():
dataset = '{}/{}'.format(metadata.get('backup-server/zfs-base'), client)
zfs_datasets[dataset] = {
'mountpoint': '/srv/backups/{}'.format(client),
}
zfs_retains[dataset] = retain_defaults.copy()
return {
'zfs': {
'datasets': zfs_datasets,
'snapshots': {
'retain_per_dataset': zfs_retains,
},
},
}