bundlewrap/bundles/backup-client/metadata.py
Franziska Kunsmann 7b9686977d
All checks were successful
kunsi/bundlewrap/pipeline/head This commit looks good
bundles/backup-client: do backups between 00:00 and 02:59
2022-03-30 17:23:10 +02:00

39 lines
1.1 KiB
Python

from hashlib import md5
defaults = {
'backup-client': {
# unix user names cannot be longer than 32 characters.
# bundlewrap raises an error if the name is longer than 30 chars.
'user-name': 'c-' + md5(node.name.encode('UTF-8')).hexdigest()[:28],
},
}
@metadata_reactor.provides(
'cron/jobs/backup',
'icinga2_api/backup-client/services',
)
def cron(metadata):
if metadata.get('backups/exclude_from_backups', False):
return {}
return {
'cron': {
'jobs': {
# spread backups between 00:00 and 04:59 UTC
'backup': '{} {} * * * root /usr/local/bin/generate-backup-with-retries'.format(
(node.magic_number % 60),
(node.magic_number % 2),
),
},
},
'icinga2_api': {
'backup-client': {
'services': {
'BACKUP LAST RUN': {
'command_on_monitored_host': '/usr/local/share/icinga/plugins/check_backup_last_run',
},
},
},
},
}