lots of stuff

This commit is contained in:
bee
2026-08-16 14:48:04 +02:00
parent c63db540e8
commit 49fa352476
45 changed files with 32520 additions and 93 deletions
+15 -6
View File
@@ -2,11 +2,22 @@
set -euo pipefail
now=$(date +"%Y%m%d%H%M")
exec 9>/var/lock/hetznerSync.lock
if ! flock -n 9
then
echo "[$(date --rfc-3339=seconds)] offsite: another sync is still running, skipping this run"
exit 0
fi
source /opt/backup/metrics.sh
metric_init offsite
trap metric_guard EXIT
if ! mountpoint -q {{ hetzner_raid_mount }}
then
echo "[${now}] {{ hetzner_raid_mount }} not mounted, refusing to sync"
log "{{ hetzner_raid_mount }} not mounted, refusing to sync"
exit 1
fi
@@ -16,19 +27,17 @@ sync_path() {
if [ -z "$(ls -A ${src} 2>/dev/null)" ]
then
echo "[${now}] ${src} empty, refusing to sync"
log "${src} empty, refusing to sync"
exit 1
fi
echo "[${now}] syncing ${src} to ${dest}"
log "syncing ${src} to ${dest}"
sudo -u {{ user }} rsync -a --delete --partial \
-e "ssh -p {{ hetzner_port }} -i {{ user_home }}/.ssh/id_ed25519 -o UserKnownHostsFile={{ user_home }}/.ssh/known_hosts -o StrictHostKeyChecking=yes" \
${src}/ \
{{ hetzner_user }}@{{ hetzner_host }}:${dest}/
}
echo "[${now}] offsite sync start"
{% for path in hetzner_paths %}
sync_path {{ path.src }} {{ path.dest }}
{% endfor %}
echo "[${now}] offsite sync done"