bundlewrap/bundles/backup-client/items.py
Franziska Kunsmann ff607777ce
All checks were successful
bundlewrap/pipeline/head This commit looks good
bundles/backup-client: support using a non-standard ssh port
2020-11-14 12:52:18 +01:00

32 lines
963 B
Python

from os.path import join
if node.metadata['backups'].get('exclude_from_backups', False):
files = {
'/etc/backup.priv': {
'delete': True,
},
}
else:
if ':' in node.metadata['backup-client']['server']:
server, port = node.metadata['backup-client']['server'].split(':')
else:
server = node.metadata['backup-client']['server']
port = 22
files = {
'/usr/local/bin/generate-backup': {
'content_type': 'mako',
'context': {
'username': node.metadata['backup-client']['user-name'],
'server': server,
'port': port,
'paths': node.metadata.get('backups', {}).get('paths', {}),
},
'mode': '0700',
},
'/etc/backup.priv': {
'content': repo.vault.decrypt_file(join('backup', 'keys', f'{node.name}.key.vault')),
'mode': '0400',
},
}