diff --git a/bundles/backup/items.py b/bundles/backup/items.py new file mode 100644 index 0000000..77d06af --- /dev/null +++ b/bundles/backup/items.py @@ -0,0 +1,14 @@ +from json import dumps + +directories['/etc/backup'] = {} + +files['/etc/backup/config.json'] = { + 'content': dumps( + { + 'server': node.metadata.get('backup/server'), + 'paths': sorted(set(node.metadata.get('backup/paths'))), + }, + indent=4, + sort_keys=True + ), +} diff --git a/bundles/backup/metadata.py b/bundles/backup/metadata.py new file mode 100644 index 0000000..9349032 --- /dev/null +++ b/bundles/backup/metadata.py @@ -0,0 +1,6 @@ +defaults = { + 'backup': { + 'server': None, + 'paths': [], + }, +} diff --git a/bundles/gitea/metadata.py b/bundles/gitea/metadata.py index 4f34f75..2c98618 100644 --- a/bundles/gitea/metadata.py +++ b/bundles/gitea/metadata.py @@ -60,6 +60,13 @@ defaults = { }, }, }, + 'zfs': { + 'datasets': { + 'tank/gitea': { + 'mountpoint': '/var/lib/gitea', + }, + }, + }, } diff --git a/bundles/nextcloud/metadata.py b/bundles/nextcloud/metadata.py index 90cf3dc..c86f3b4 100644 --- a/bundles/nextcloud/metadata.py +++ b/bundles/nextcloud/metadata.py @@ -31,7 +31,7 @@ defaults = { }, }, 'backup': { - 'files': [ + 'paths': [ '/etc/nextcloud/config.php', ], }, @@ -61,7 +61,7 @@ defaults = { }, 'zfs': { 'datasets': { - 'tank/nexcloud': { + 'tank/nextcloud': { 'mountpoint': '/var/lib/nextcloud', }, }, diff --git a/bundles/postfix/metadata.py b/bundles/postfix/metadata.py index 3b610e5..decb1d8 100644 --- a/bundles/postfix/metadata.py +++ b/bundles/postfix/metadata.py @@ -5,6 +5,11 @@ defaults = { 'postfix-pgsql': {}, } }, + 'backup': { + 'paths': [ + '/var/vmail', + ], + }, 'letsencrypt': { 'reload_after': { 'postfix', diff --git a/bundles/postgresql/metadata.py b/bundles/postgresql/metadata.py index 46dc13d..fcc5dd3 100644 --- a/bundles/postgresql/metadata.py +++ b/bundles/postgresql/metadata.py @@ -1,4 +1,14 @@ defaults = { + 'apt': { + 'packages': { + 'postgresql': {}, + }, + }, + 'backup': { + 'paths': [ + '/var/lib/postgresql', + ], + }, 'postgresql': { 'roles': { 'root': { @@ -8,11 +18,6 @@ defaults = { }, 'databases': {}, }, - 'apt': { - 'packages': { - 'postgresql': {}, - }, - }, } if node.has_bundle('zfs'): diff --git a/bundles/zfs/metadata.py b/bundles/zfs/metadata.py index 690461a..b7a24de 100644 --- a/bundles/zfs/metadata.py +++ b/bundles/zfs/metadata.py @@ -54,3 +54,17 @@ def dataset_defaults(metadata): }, }, } + + +@metadata_reactor.provides( + 'backup/paths' +) +def backup(metadata): + return { + 'backup': { + 'paths': [ + options['mountpoint'] for options in metadata.get('zfs/datasets').values() + if options.get('backup', True) + ], + }, + } diff --git a/groups/all.py b/groups/all.py index 2e8e687..6697eee 100644 --- a/groups/all.py +++ b/groups/all.py @@ -1,5 +1,11 @@ { + 'bundles': [ + 'backup', + ], 'metadata': { + 'backup': { + 'server': 'backups.sublimity.de', + }, 'dns': {}, } } diff --git a/nodes/htz.mails.py b/nodes/htz.mails.py index 54af51a..b997087 100644 --- a/nodes/htz.mails.py +++ b/nodes/htz.mails.py @@ -9,11 +9,10 @@ 'dnsserver', ], 'bundles': [ - 'gcloud', 'wireguard', + 'nextcloud', #TEMP + 'influxdb2', #TEMP 'zfs', - 'nextcloud', - 'influxdb2', ], 'metadata': { 'bind': {