2020-11-13 11:36:52 +00:00
|
|
|
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],
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-01-07 17:44:38 +00:00
|
|
|
@metadata_reactor.provides(
|
2022-02-05 10:41:41 +00:00
|
|
|
'cron/jobs/backup',
|
2021-01-07 17:44:38 +00:00
|
|
|
'icinga2_api/backup-client/services',
|
|
|
|
)
|
2020-11-13 11:36:52 +00:00
|
|
|
def cron(metadata):
|
|
|
|
if metadata.get('backups/exclude_from_backups', False):
|
|
|
|
return {}
|
|
|
|
|
|
|
|
return {
|
|
|
|
'cron': {
|
2022-02-05 10:41:41 +00:00
|
|
|
'jobs': {
|
2022-01-04 14:34:53 +00:00
|
|
|
# spread backups between 00:00 and 04:59 UTC
|
2022-02-05 10:41:41 +00:00
|
|
|
'backup': '{} {} * * * root /usr/local/bin/generate-backup-with-retries'.format(
|
|
|
|
(node.magic_number % 60),
|
2022-03-30 15:23:10 +00:00
|
|
|
(node.magic_number % 2),
|
2022-02-05 10:41:41 +00:00
|
|
|
),
|
|
|
|
},
|
2020-11-13 11:36:52 +00:00
|
|
|
},
|
2021-01-01 12:59:42 +00:00
|
|
|
'icinga2_api': {
|
|
|
|
'backup-client': {
|
|
|
|
'services': {
|
|
|
|
'BACKUP LAST RUN': {
|
|
|
|
'command_on_monitored_host': '/usr/local/share/icinga/plugins/check_backup_last_run',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2020-11-13 11:36:52 +00:00
|
|
|
}
|