From 17ae9bcf18ab06ac3061748a1b0ff2ecda3c6dc7 Mon Sep 17 00:00:00 2001 From: mwiegand Date: Tue, 13 Jul 2021 01:24:54 +0200 Subject: [PATCH] wip --- bundles/backup-server/metadata.py | 6 ++++++ bundles/backup/files/backup_path_via_rsync | 11 +++++++++++ bundles/zfs/metadata.py | 3 ++- 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/bundles/backup-server/metadata.py b/bundles/backup-server/metadata.py index 3139db4..2128622 100644 --- a/bundles/backup-server/metadata.py +++ b/bundles/backup-server/metadata.py @@ -1,6 +1,11 @@ from ipaddress import ip_interface defaults = { + 'apt': { + 'packages': { + 'rsync': {}, + }, + }, 'users': { 'backup-receiver': { 'authorized_keys': [], @@ -32,6 +37,7 @@ def zfs(metadata): # for rsync backups datasets[f"tank/{other_node.metadata.get('id')}/fs"] = { 'mountpoint': f"/mnt/backups/{other_node.metadata.get('id')}", + 'readonly': 'off', 'backup': False, } diff --git a/bundles/backup/files/backup_path_via_rsync b/bundles/backup/files/backup_path_via_rsync index e69de29..32fbcf2 100644 --- a/bundles/backup/files/backup_path_via_rsync +++ b/bundles/backup/files/backup_path_via_rsync @@ -0,0 +1,11 @@ +#!/bin/bash + +set -exu + +path=$1 +uuid=$(jq -r .client_uuid < /etc/backup/config.json) +server=$(jq -r .server_hostname < /etc/backup/config.json) +ssh="ssh -o StrictHostKeyChecking=no -o ConnectTimeout=5 backup-receiver@$server" + +rsync -av --rsync-path="sudo rsync" "$path/" "backup-receiver@$server:/mnt/backups/$uuid$path/" +$ssh sudo zfs snap "tank/$uuid/fs@auto-backup_$(date +"%Y-%m-%d_%H:%M:%S")" diff --git a/bundles/zfs/metadata.py b/bundles/zfs/metadata.py index bf9389e..f134078 100644 --- a/bundles/zfs/metadata.py +++ b/bundles/zfs/metadata.py @@ -74,7 +74,8 @@ def backup(metadata): return { 'backup': { 'paths': [ - options['mountpoint'] for options in metadata.get('zfs/datasets').values() + options['mountpoint'] + for options in metadata.get('zfs/datasets').values() if options.get('backup', True) ], },