From 72561bdb52f63840abfd5572d68fdb480ea94aaa Mon Sep 17 00:00:00 2001 From: mwiegand Date: Fri, 12 Nov 2021 16:59:57 +0100 Subject: [PATCH] backup openhab --- bundles/backup-server/metadata.py | 9 ++++++++- bundles/backup/files/backup_path_via_zfs | 2 +- bundles/backup/metadata.py | 12 ++++++++++-- nodes/home.openhab.py | 5 +++-- 4 files changed, 22 insertions(+), 6 deletions(-) diff --git a/bundles/backup-server/metadata.py b/bundles/backup-server/metadata.py index 36d46b6..de777d7 100644 --- a/bundles/backup-server/metadata.py +++ b/bundles/backup-server/metadata.py @@ -40,9 +40,16 @@ def zfs(metadata): 'readonly': 'off', 'backup': False, } - # for zfs send/recv if other_node.has_bundle('zfs'): + # base datasets for each tank + for pool in other_node.metadata.get('zfs/pools'): + datasets[f"tank/{other_node.metadata.get('id')}/{pool}"] = { + 'mountpoint': None, + 'readonly': 'on', + 'backup': False, + } + # actual datasets for path in other_node.metadata.get('backup/paths'): for dataset, config in other_node.metadata.get('zfs/datasets').items(): if path == config.get('mountpoint'): diff --git a/bundles/backup/files/backup_path_via_zfs b/bundles/backup/files/backup_path_via_zfs index 816d46c..fb97083 100644 --- a/bundles/backup/files/backup_path_via_zfs +++ b/bundles/backup/files/backup_path_via_zfs @@ -45,7 +45,7 @@ fi if [[ "$?" == "0" ]] then zfs bookmark "$source_dataset@$new_bookmark" "$source_dataset#$new_bookmark" - zfs destroy "$source_dataset@$new_bookmark" + #zfs destroy "$source_dataset@$new_bookmark" # keep snapshots? echo "SUCCESS" else zfs destroy "$source_dataset@$new_bookmark" diff --git a/bundles/backup/metadata.py b/bundles/backup/metadata.py index 3a8af00..3d0a716 100644 --- a/bundles/backup/metadata.py +++ b/bundles/backup/metadata.py @@ -1,8 +1,16 @@ defaults = { 'apt': { 'packages': { - 'jq': {}, - 'rsync': {}, + 'jq': { + 'needed_by': { + 'svc_systemd:backup.timer', + }, + }, + 'rsync': { + 'needed_by': { + 'svc_systemd:backup.timer', + }, + }, }, }, 'backup': { diff --git a/nodes/home.openhab.py b/nodes/home.openhab.py index e8e29ad..e21774d 100644 --- a/nodes/home.openhab.py +++ b/nodes/home.openhab.py @@ -1,9 +1,10 @@ { 'hostname': '10.0.0.17', 'groups': [ - 'raspberry-pi', + 'backup', 'debian-11', 'monitored', + 'raspberry-pi', 'webserver', ], 'bundles': [ @@ -39,7 +40,7 @@ 'pools': { 'tank': { 'devices': [ - '/dev/sda', + '/dev/mmcblk1p3', ], }, },