2020-11-14 13:35:54 +00:00
|
|
|
defaults = {
|
|
|
|
'openssh': {
|
|
|
|
'allowed_users': {
|
|
|
|
# Usernames for backup clients always start with 'c-'
|
|
|
|
'c-*',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
2021-01-07 17:44:38 +00:00
|
|
|
@metadata_reactor.provides(
|
|
|
|
'backup-server/clients',
|
|
|
|
)
|
2020-11-13 11:36:52 +00:00
|
|
|
def get_my_clients(metadata):
|
|
|
|
my_clients = {}
|
|
|
|
|
|
|
|
for rnode in repo.nodes:
|
2020-11-13 20:56:15 +00:00
|
|
|
if rnode.metadata.get('backups/exclude_from_backups', False) or rnode.dummy:
|
2020-11-13 11:36:52 +00:00
|
|
|
continue
|
|
|
|
|
|
|
|
my_clients[rnode.name] = {
|
|
|
|
'user': rnode.metadata.get('backup-client/user-name'),
|
|
|
|
}
|
|
|
|
|
|
|
|
return {
|
|
|
|
'backup-server': {
|
|
|
|
'clients': my_clients,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-01-07 17:44:38 +00:00
|
|
|
@metadata_reactor.provides(
|
|
|
|
'zfs/datasets',
|
|
|
|
'zfs/snapshots/retain_per_dataset',
|
|
|
|
)
|
2020-11-13 11:36:52 +00:00
|
|
|
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,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|