This commit is contained in:
mwiegand 2021-07-13 01:24:54 +02:00
parent 86946636c4
commit 17ae9bcf18
3 changed files with 19 additions and 1 deletions

View file

@ -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,
}

View file

@ -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")"

View file

@ -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)
],
},